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

Empty name prevented devices from being added #41

Closed
zackman0010 opened this issue Sep 8, 2021 · 7 comments
Closed

Empty name prevented devices from being added #41

zackman0010 opened this issue Sep 8, 2021 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@zackman0010
Copy link

After fixing the www. issue described in #37, I was greeted with a new error message.

[9/8/2021, 09:09:39] [Vivint] Error while bootstrapping accessories: AssertionError [ERR_ASSERTION]: Accessories must be created with a non-empty displayName.
at new Accessory (/usr/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:400:11)
at new PlatformAccessory (/usr/lib/node_modules/homebridge/src/platformAccessory.ts:70:9)
at Function.createDeviceAccessory (/usr/lib/node_modules/@balansse/homebridge-vivint/lib/device_set.js:147:23)
at /usr/lib/node_modules/@balansse/homebridge-vivint/index.js:55:50
at Array.map ()
at /usr/lib/node_modules/@balansse/homebridge-vivint/index.js:55:20
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: '',
expected: true,
operator: '=='
}

After a bit of investigation, I found that it was the Nest Thermostat. The VivInt update had wiped the Name field, it was showing blank in the app. I had to remove and readd the thermostat to my VivInt account to let it regain its name. However, this one error with the thermostat prevented all other devices being registered by the VivInt plugin. The error message also made it very unclear which device was at fault. Maybe this error could be caught to provide better info?

@balansse balansse self-assigned this Sep 9, 2021
@balansse balansse added the bug Something isn't working label Sep 9, 2021
@balansse
Copy link
Owner

@jgrimard I see you reverted the commit fixing this issue - can you tell me more about the reason?

@jgrimard
Copy link

jgrimard commented Sep 20, 2021

@balansse I have no way of testing it myself. I only have a base Vivint alarm system with sensors and a couple of zwave outlets linked to it. I was going to have @zackman0010 test it but he got it working by reconnecting the thermostat to his alarm panel. So I didn't want to make any changes without testing first.
Plus I'm not really sure if it is just failing to send the display name, or if there is other important data not being sent.

@zackman0010
Copy link
Author

The name came across as empty string "" rather than null, so I don't think the change that was in the PR would have worked. It's been a long time since I worked with JavaScript, but I'm pretty sure a || b only uses b if a is null.

@jgrimard
Copy link

Hi @zackman0010
It would work the same if it was and empty string or null.

From: https://stackoverflow.com/questions/2100758/javascript-or-variable-assignment-explanation

The following values are considered falsy in JavaScript.
false
null
"" (empty string)
0
Nan
undefined

@zackman0010
Copy link
Author

Then your change most likely would have worked. The only thing wrong with the response was that name was empty, and supplying a default value would have fixed that.

@jgrimard
Copy link

I don't think that code would have fixed the issue. I just did a little testing and found that changing that line in device.js doesn't appear to do anything visible.

I tried changing it to this, to simulate an empty string coming in:

        this.name = accessory.context.name
        this.name = ""
        log.info("name = " + this.name)

I got the below output in my logs and my accessories will still all named correctly. I even cleared the accessory cache. No crash at all.

[9/20/2021, 3:43:54 PM] [Vivint] Removing 0 accessories
[9/20/2021, 3:43:54 PM] [Vivint] Adding 3 accessories
[9/20/2021, 3:43:54 PM] [Vivint] name = 
[9/20/2021, 3:43:54 PM] [Vivint] name = 
[9/20/2021, 3:43:54 PM] [Vivint] name = 

So it looks like the crash is coming from somewhere else.

@NicoCanada
Copy link

Hello there,
I run into this issue and I found it is related to my Nest Thermostat connected to Vivint.
Since I am new to this project, I don't know how everything works together.
Here is the code in /usr/lib/node_modules/@balansse/homebridge-vivint/lib/device_set.js

...
if (splittedName.length > 1) {
          model = splittedName[1].toUpperCase()
        }
      }
      log.info(data) // log data 
      let accessory = new PlatformAccessory(
        data.Name + '1', // dirty fix
        uuid.generate("Vivint:" + data.Id + ":" + serial),
        category)

I used log.info(data) at line 144 and check what is before the error.
The follow was from the log.

...  },
  Online: true,
  Features: { Features_HVAC_AWAY_SETBACK: true, Features_HVAC_SCHEDULES: true },
  Name: '',
  Type: 'thermostat_device',
  WeekdayHeatSchedule: [
    {

I hope the information can help you a bit.
Thanks for the wonderful work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants