datMaffin / homebridge-tesla-powerwall

Homebridge Plugin for the Tesla Powerwall
ISC License
21 stars 11 forks source link

Regular Warning message Undefined characteristic #34

Closed gdotp01 closed 2 years ago

gdotp01 commented 2 years ago

A great plugin, thanks for writing it. I recently updated a few dependencies and I’m now getting an u defined characteristic warning regularly in the homebridge logs.

Homebridge 1.3.8 Node 16.13.1 Non 8.1.2

29F244BA-9F54-4B6D-937B-82C4D5EA1A4B

datMaffin commented 2 years ago

(Accidentally responded before I finished with writing an answer; it turns out shift+return submits the comment ;) )

Hi, thanks for the report!

What version of this plugin are you using?


Following are a few notes for me to get an overview:

I am guessing that the following characteristic is triggering the warning: https://github.com/datMaffin/homebridge-tesla-powerwall/blob/fe71c940a22e67689822e1f6ec139f22cbef7952/src/accessories/powermeter.js#L80-L83

However, the code looks like it can not return undefined: https://github.com/datMaffin/homebridge-tesla-powerwall/blob/fe71c940a22e67689822e1f6ec139f22cbef7952/src/accessories/powermeter.js#L159-L163

When a recent version is used, it may use _fastGetter; check if undefined is possibly returned from there https://github.com/datMaffin/homebridge-tesla-powerwall/blob/fe71c940a22e67689822e1f6ec139f22cbef7952/src/helper/fast-getter.js.

Characteristic is defined here: https://github.com/datMaffin/homebridge-tesla-powerwall/blob/fe71c940a22e67689822e1f6ec139f22cbef7952/index.js#L493-L505

Message seems to be created by this code: https://github.com/homebridge/HAP-NodeJS/blob/03431b8f93137f4c969888a3d631f52da5b787b6/src/lib/Characteristic.ts#L1966-L1969

gdotp01 commented 2 years ago

Thanks for getting back. I’m on v2.2.0 of the plug-in which is the latest I think.

gdotp01 commented 2 years ago

Hello.Any updates as to what is causing this? The warning is signalled just under every hour in the log file.

datMaffin commented 2 years ago

I currently do not have a good setup for testing and debugging.

However, I took a second look at my notes. I noticed that it is pretty likely that

https://github.com/datMaffin/homebridge-tesla-powerwall/blob/fe71c940a22e67689822e1f6ec139f22cbef7952/src/accessories/powermeter.js#L159-L163

actually does contain a bug. The callback takes (error, value) as arguments. Meaning that the calculation is passed to the error field, while the value field will be undefined.

In the following days, I will try to prepare a version that should fix this issue, which can then be installed for testing purposes.

gdotp01 commented 2 years ago

Great thanks. I can test it if you need

datMaffin commented 2 years ago

There is now a version uploaded to npm that contains the change that may fix this issue. Use sudo npm install -g homebridge-tesla-powerwall@3.0.0-Beta to install it.

gdotp01 commented 2 years ago

Ok I’ll give it a try. Thanks

gdotp01 commented 2 years ago

All seems to be working well.

datMaffin commented 2 years ago

Ok. Thanks for reporting back 👍