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

lastActivation: duplicate key #98

Closed
torandreroland opened this issue Jan 26, 2023 · 10 comments
Closed

lastActivation: duplicate key #98

torandreroland opened this issue Jan 26, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@torandreroland
Copy link
Contributor

torandreroland commented Jan 26, 2023

I get an SyntaxError in the logs in the latest version (not present in v0.0.27). I think this is related to a motion sensor:

Ekraveien 18: error: SyntaxError: lastActivation: duplicate key
at Motion.addCharacteristicDelegate (/homebridge/node_modules/homebridge-deconz/node_modules/homebridge-lib/lib/ServiceDelegate/index.js:242:13)
at new Sensor (/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Sensor.js:73:48)
at Gateway.addAccessory (/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:612:25)
at Gateway.analyseFullState (/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:1068:20)
at Gateway.poll (/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:903:18)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at Gateway.heartbeat (/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:339:9)

When updating from v.0.0.27 to 0.1.2 I had to do a full unexposed and expose of the whole gateway to get a functional setup. This error occurred after the first restart of homebridge after that.

homebridge-deconz.json is available here.

@ebaauw ebaauw added the bug Something isn't working label Jan 27, 2023
@ebaauw
Copy link
Owner

ebaauw commented Jan 27, 2023

That's a bug alright, thanks for reporting and for providing the dump file.

Homebridge deCONZ chokes on the Samjin multisensor, which combines a door/window sensor (ZHAOpenClose), a temperature sensors (ZHATemperature), and a vibration sensor (ZHAVibration). Homebridge deCONZ should expose it as a single accessory with Contact Sensor, Temperature Sensor, and Motion Sensor services, incl. Eve history for all three. The bug is that it adds the Last Activiation characteristic for the Motion Sensor to the primary service, instead of to the Motion Sensor service. Usually, for motion sensors, the primary service is the Motion Sensor service, but for the multi sensor, the Context Sensor is the primary.

ebaauw added a commit that referenced this issue Jan 27, 2023
Bug fix: SyntaxError: lastActivation: duplicate key.
For multi-sensor with Contact and Motion service , see #98.
@ebaauw
Copy link
Owner

ebaauw commented Jan 27, 2023

Could you try beta v0.1.3-0?

@torandreroland
Copy link
Contributor Author

Thanks! Can confirm it's working in beta v0.1.3-0 after removing the accessory from cache first.

Closing this.

@torandreroland
Copy link
Contributor Author

@ebaauw: I am reopening this issue. It stills fails with the same error. It happens after the first restart after first activation of the motion sensor.

If I then go into the cachedAccessories and delete lastActivation for the motion sensor, the service is created correctly. But if I then activate the sensor and restart homebridge, the error reappears.

@ebaauw
Copy link
Owner

ebaauw commented Feb 12, 2023

See #111 it looks like deCONZ changed how it exposed the sensor? Messing with cachedAccessories is a very bad idea, and only impacts the structures maintained by Homebridge. It won’t change how Homebridge deCONZ creates the delegates from the full state reported by the deCONZ API.

@torandreroland
Copy link
Contributor Author

torandreroland commented Feb 13, 2023

Thank you for your quick reply!

An updated homebridge-deconz.json is available here. For comparison the homebridge-deconz.json from the first post is still available here.

I don't like messing around in cachedAccessories either, but it sure beats having to restore from backup using Controller for HomeKit to restore room information, scenes and automations while troubleshooting this. I believe lastActivation is just handled internally by this plugin as it doesn't look to be exposed in the deCONZ REST-API.

I'm not quite sure commit 94d5e3d at any point solved this issue. 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).

Please note: I have been setting the DDF Mode of Deconz to strict lately (due to incorrect handling in legacy code for some other device I have). I haven't experiences that this has affected the Samsung multi-sensor, but I though I should mention it since you asked if deCONZ changed how it exposed the sensor.

@ebaauw
Copy link
Owner

ebaauw commented Feb 13, 2023

I believe lastActivation is just handled internally by this plugin

Yes, same for Times Opened.

I'm not quite sure commit 94d5e3d at any point solved this issue

No, it didn't; I missed the same issue for the Contact Sensor.

I don't believe Contact Sensor is the primary service

No, the Motion Sensor is. Another bug, but with the rework of Eve history, I'm now able to create any combination (up to seven characteristics), and the notion of primary service has become irrelevant for sensors.

I haven't experiences that this has affected the Samsung multi-sensor, but I though I should mention it since you asked if deCONZ changed how it exposed the sensor.

No, it hasn't. I was under the assumption that the previous commit had solved the issue, which it only would have when the Contact Sensor was the primary service.

ebaauw added a commit that referenced this issue Feb 13, 2023
Bug fix: _Contact Sensor_ listed wrongly, so it wasn't considered determining the primary service, see #98.
ebaauw added a commit that referenced this issue Feb 13, 2023
- Bug fix (take 2) SyntaxError: lastActivation: duplicate key.
For multi-sensor with Contact and Motion service , see #98.
- Initialise _Times Opened_ to 0, see #111.
@ebaauw
Copy link
Owner

ebaauw commented Feb 13, 2023

Could you try beta v0.1.5-0?

@torandreroland
Copy link
Contributor Author

Works in beta v0.1.5-0. Closing this issue again. Thank you for your help.

@ebaauw
Copy link
Owner

ebaauw commented Feb 19, 2023

Released v0.1.7.

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

2 participants