Jason-Morcos / homebridge-magic-occupancy

Occupancy sensor linked to one or more switches with a built-in delay not-unoccupied delay for Homebridge
GNU General Public License v3.0
78 stars 3 forks source link

Delay Timer triggers by reboot persistent stateful (manual) switches #10

Closed WRTHacker closed 2 years ago

WRTHacker commented 2 years ago

Config:

{ "name": "WLAN Anwesend Delay", "stayOccupiedDelay": 300, "persistBetweenReboots": true, "startOnReboot": false, "statefulSwitchesNames": "WLAN Anwesend Verzögerung", "createMasterShutoff": false, "_bridge": { "username": "0E:03:25:73:D7:AB", "port": 54137 }, "accessory": "MagicOccupancy" }

After a reboot, the state is correct, but after the delay time I see the following in the logs;

[11/6/2021, 7:13:15 PM] [WLAN UniFi anwesend] 1 monitored device(s) found. Accessory is in mode "any" so triggering occupancy. [11/6/2021, 7:13:17 PM] [WLAN Anwesend Delay] Cancel timer and set occupancy to "NotDetected" [11/6/2021, 7:13:17 PM] [WLAN Anwesend Delay] Delay timer stopped

An automation sets the switch "WLAN Anwesend Delay") to on (it was on due to the persistent) when a device is found in the WiFi "WLAN Unifi anwesend" switch. Whe nthis happpens, the next line shows that the switch "WLAN Anwesend Delay" is set to NotDetected, occupancy is not set, and another outomation triggers.

This should not happen.

Please contact me, if you need more information.

Jason-Morcos commented 2 years ago

I'm a little confused, are you saying the switch and occupancy sensor both preserve their state properly, but shortly after restart the switch toggles off? What state were they expected to be when the home bridge powers on? Both on? I don't think I quite understand what's happening here but it sounds like maybe the Home app is the side doing something funky, running an automation that toggles the switch back off?

WRTHacker commented 2 years ago

Ok, I will tra to clarify:

Automation:

Together:

Jason-Morcos commented 2 years ago

Thank you for the additional clarification! I think I found and fixed the issue. The very first reboot after the update will still have the bug, but if I've fixed it it should work as expected for future reboots. Please give it a try and let me know if the issue persists or if you find any other issues! https://github.com/Jason-Morcos/homebridge-magic-occupancy/releases/tag/3.0.1

WRTHacker commented 2 years ago

Hi Jason-Morcos, seems to work properly now. Many thanks for support and quick fix! Best regards