ebaauw / homebridge-deconz

Homebridge plugin for deCONZ
Apache License 2.0
135 stars 7 forks source link

timesOpened should be instanced with 0 #111

Closed torandreroland closed 1 year ago

torandreroland commented 1 year ago

Characteristic timesOpened is according to cachedAccessories instanced with value null which leads to warning:

[homebridge-deconz] This plugin generated a warning from the characteristic 'Times Opened': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.

I believe timesOpened should be instanced to 0 the first time.

Additionally the characteristic is added to the motion sensor service, but I would presume it should be added to contact sensor service.

ebaauw commented 1 year ago

Is this the Samsung multi-sensor from #98?

Damn, it looks to be the same bug as fixed in https://github.com/ebaauw/homebridge-deconz/commit/94d5e3d1f788f699f90b799bd4e63238e1d5ca6f, but on the Contact Sensor, instead of on the Motion Sensor. Missed those instances.

I don’t quite understand why it worked before, though. It looks like the Contact Sensor no longer is the primary service. Did deCONZ change the way it exposes the sensor, or did you delete resources from deCONZ?

torandreroland commented 1 year ago

See part of comment in #98:

I'm not quite sure commit https://github.com/ebaauw/homebridge-deconz/commit/94d5e3d1f788f699f90b799bd4e63238e1d5ca6f at any point solved issue https://github.com/ebaauw/homebridge-deconz/issues/98. It happens after first restart after I have activated the sensor (ie. opened the window), which in retrospect I didn't try before closing that issue originally.

I don't believe Contact Sensor is the primary service (or ever was). At least the json says "primary": "01-FC02" which is the ZHAVibration resource which I believe is the basis for a motion sensor service (ZHATemperature I assume is the basis for Temperature Sensor service and ZHAOpenClose should be the basis for Contact Sensor service).

ebaauw commented 1 year ago

Not sure if the message was the result of Times Opened being added to the wrong service, or due to initialisation, but it never hurts to initialise it explicitly.

torandreroland commented 1 year ago

Observed the times opened characteristic in beta v0.1.5-0. It is still added to the motion sensor service instead of the contact sensor. Additionally it isn't updated anymore when opening/closing the contact sensor.

I don't know if this is due to some migration issue from the old to the new characteristic, but I noticed this in the logging when restarting the first time after updating to beta v0.1.5-0 (for all such contact sensors):

Home Office Window Sensor: remove stale characteristic Times Opened Home Office Window Sensor: remove stale value timesOpened

ebaauw commented 1 year ago

Observed the times opened characteristic in beta v0.1.5-0. It is still added to the motion sensor service instead of the contact sensor. Additionally it isn't updated anymore when opening/closing the contact sensor.

How long after restarting Homebridge did you see this? HomeKit doesn't like configuration changes, and it might take a couple of minutes before the changes are reflected in HomeKit.

Could you try v0.1.7? Does the issue still occur after a while? And after un-exposing and re-exposing the sensor?

If so, please attached the cachedAccessories file for this Homebridge instance.

The messages indicate that Homebridge deCONZ is cleaning up stale characteristics - I would hope from the Motion Sensor.

torandreroland commented 1 year ago

I can confirm that the characteristic is successfully added to the contact sensor and it's being updated as well.

This was tested on version 0.1.7, but it may be that I just didn't allow enough time for the changes to be reflected in HomeKit.

Closing this issue. Thank you for your help!