Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidecar request for balansse/homebridge-vivint #4

Closed
jgrimard opened this issue Sep 27, 2021 · 12 comments
Closed

Sidecar request for balansse/homebridge-vivint #4

jgrimard opened this issue Sep 27, 2021 · 12 comments

Comments

@jgrimard
Copy link

Due to a new 2FA requirement by Vivint, I have modified https://github.com/balansse/homebridge-vivint to use the Homebridge Custom UI. I based it off of Homebridge-Ring and it works great. There are many users who use the homebridge-vivint plugin in HOOBS who can't use the new interface. Can you create a sidecar for the HOOBS users?

@3ne
Copy link

3ne commented Sep 27, 2021

This request is highly recommended and would be appreciated by those not familiar with terminal.

@robbhudson
Copy link

Agreed, I'm very new to this and went to Hoobs because it is easy. Now picking through other threads to get this working again manually is proving somewhat difficult.

@mkellsy
Copy link
Contributor

mkellsy commented Sep 29, 2021

This is coming. I have to develop it. A sidecar gives us the ability to make a UI plugin without having to disturb the developer. Developers can do this too and I am willing to work with the dev too.

@mkellsy
Copy link
Contributor

mkellsy commented Oct 27, 2021

This is done. You can get it by re-installing the plugin.

  1. Go to the plugin page
  2. Click on the Versions tab
  3. Click on the Latest tag
  4. Select the current bridge it's installed on

You will see the Link Account button as soon as the bridge restarts.

@mrfletch
Copy link

mrfletch commented Oct 28, 2021

Thanks for your work on this @mkellsy.

Forgive me if I've done something wrong — I'm a new Hoobs member. Just plugged in my HOOBS All In One Box.

  1. I've installed @jgrimard’s Homebridge Vivint plugin v1.6.0 which is marked as the latest version.
  2. Inside the Configuration area I tap Link Account
  3. A modal opens asking for my Vivint email and password
  4. I enter my login credentials and click/tap "Login"

At this stage, nothing happens. I've tried Safari, Chrome, and Firefox, and the Hoobs desktop Mac app too.

Any advice?

Additional details:
Version: 4.1.11
Node Version 14.18.1
Homebridge Version: 1.3.5
System Version: 11

@askovi
Copy link
Member

askovi commented Oct 28, 2021

I can confirm the bug reported by @mrfletch
Debug info below @mkellsy :

image

@mkellsy
Copy link
Contributor

mkellsy commented Oct 31, 2021

Had to fix this UI plugin. You can get the update by re-installing the plugin.

  1. Go to the plugin page
  2. Click on the Versions tab
  3. Click on the Latest tag
  4. Select the current bridge it's installed on

You will see the Link Account button as soon as the bridge restarts.

@mrfletch
Copy link

mrfletch commented Oct 31, 2021

I appreciate all your work on this @mkellsy.

After a fresh install of v1.6.0 the login button now directs me to a spinner, however, after a delay of several seconds the username and password fields reappear without any messaging positive or negative.

Here's what I see in the logs:

10/31/2021, 12:30:06 AMVivint BridgeBridge change
10/31/2021, 12:30:17 AMVivint BridgeInitializing HAP-NodeJS v0.9.6...
10/31/2021, 12:30:24 AMVivint BridgeLoaded plugin '@balansse/homebridge-vivint'
10/31/2021, 12:30:25 AMVivint Bridge�[90mPlugin '@balansse/homebridge-vivint' tried to register with an incorrect plugin identifier: 'homebridge-vivint'. Please report this to the developer!�[39m
10/31/2021, 12:30:25 AMVivint BridgeRegistering platform '@balansse/homebridge-vivint.Vivint'
10/31/2021, 12:30:25 AMVivint BridgeLoading 1 platforms...
10/31/2021, 12:30:25 AMVivint BridgePreparing Advertiser for 'Vivint Bridge 90BB' using bonjour-hap backend!
10/31/2021, 12:30:25 AMVivint BridgeSetup URI 'X-HM://0023ISYWYZTK4'
10/31/2021, 12:30:25 AMVivint BridgeStarting to advertise 'Vivint Bridge 90BB' using bonjour-hap backend!
10/31/2021, 12:30:25 AMVivint BridgeBridge is running on port 51856.

I'm a designer by trade so don't contest to know much in the development field, but in an effort to be helpful I noticed in the app.js file the response on line 36 is coming back empty. Hope this helps!

No Response

A little bit later in the evening, I noticed this appear the logs:

10/31/2021, 2:18:57 AMVivint BridgeVivintERRORError occured during login, retrying in 60 seconds... RequestError: Error: getaddrinfo EAI_AGAIN www.vivintsky.com
    at new RequestError (/var/lib/hoobs/vivintbridge/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/var/lib/hoobs/vivintbridge/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/var/lib/hoobs/vivintbridge/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/var/lib/hoobs/vivintbridge/node_modules/request/request.js:185:22)
    at Request.emit (events.js:400:28)
    at Request.onRequestError (/var/lib/hoobs/vivintbridge/node_modules/request/request.js:877:8)
    at ClientRequest.emit (events.js:400:28)
    at TLSSocket.socketErrorListener (_http_client.js:475:9)
    at TLSSocket.emit (events.js:400:28)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  cause: Error: getaddrinfo EAI_AGAIN www.vivintsky.com
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:71:26) {
    errno: -3001,
    code: 'EAI_AGAIN',
    syscall: 'getaddrinfo',
    hostname: 'www.vivintsky.com'
  },
  error: Error: getaddrinfo EAI_AGAIN www.vivintsky.com
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:71:26) {
    errno: -3001,
    code: 'EAI_AGAIN',
    syscall: 'getaddrinfo',
    hostname: 'www.vivintsky.com'
  },
  options: {
    url: 'https://www.vivintsky.com/api/authuser',
    headers: { Cookie: undefined },
    resolveWithFullResponse: true,
    callback: [Function: RP$callback],
    transform: undefined,
    simple: true,
    transform2xxOnly: false
  },
  response: undefined
}

Thanks,
Paul

@jgrimard
Copy link
Author

jgrimard commented Nov 3, 2021

@mkellsy
I found a typo in app.js that was preventing the MFA code from being sent to Vivint. Please fix this. However the authToken is still not being saved to the config. I'm not sure why. I haven't found a good way to debug HOOBS like I can with Homebridge.

async function validate() {
    // const code = fields.verification.value;
    const code = fields.code.value;
    const token = fields.token.value;

Pull Request: #9

@jgrimard
Copy link
Author

jgrimard commented Nov 4, 2021

@mkellsy,
I figured out why the config is not saving. But I don't know enough about the inner workings of HOOBS to know the best way to fix it. Basically, when you try to save refreshToken to the config, HOOBS attempts to figure out which plugin to save to by comparing the plugin name. One part of HOOBS is calling the plugin "homebridge-vivint" and the other part is calling it "@balansse/homebridge-vivint", so it never gets saved.

Here are my notes on tracking down the issue.

In config.ts, this.name does not have the @scope prefix: this.name = homebridge-vivint
However, the plugin_map does have the @scope prefix : plugin_map: { plugin_name: '@balansse/homebridge-vivint' }
So when it searches for the index, it returns -1, since the names don't match.
This index=-1 causes the config to not get saved.

https://github.com/hoobs-org/hoobsd/blob/main/src/services/plugins.ts#L67
load() function sets the plugin name using: name: PluginManager.extractPluginName(pjson.name)

https://github.com/homebridge/homebridge/blob/master/src/pluginManager.ts#L91
public static extractPluginName(name: string): PluginName { // extract plugin name without @scope/ prefix

https://github.com/hoobs-org/hoobsd/blob/main/src/bridge/index.ts#L85
const config = new Config(plugins[i].name);

https://github.com/hoobs-org/hoobsd/blob/main/src/services/config.ts#L244
const index = this.config.platforms.findIndex((p: any) => (p.plugin_map || {}).plugin_name === this.name);

https://github.com/hoobs-org/hoobsd/blob/main/src/services/config.ts#L246
if (index >= 0) {

@mkellsy
Copy link
Contributor

mkellsy commented Nov 7, 2021

Sorry for the delay. Been under the weather this week (not COVID). I found the issue and I am releasing 4.1.13 today, it’s currently building.

The issue was when initializing the UI plugin I was passing in the name and not the identifier. Plugins have 2 names, 1. The identifier - name as NPM, 2. The alias - the name in the config. This is why there is a plugin-map in our configs.

From time to time I get these 2 names mixed up.

@jgrimard
Copy link
Author

jgrimard commented Nov 8, 2021

@mkellsy
I just tested HOOBS 4.1.13 and the homebridge-vivint login process is now working. I'm going to close this issue. Thank you.

@jgrimard jgrimard closed this as completed Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants