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

This plugin is not compatible with HB 2.0 #50

Closed pfrasun closed 2 weeks ago

pfrasun commented 2 months ago

This plugin is sadly not compatible with HB 2.0. After installing HB 2.0 Beta 11 plugin does not start properly and ends in the endless restart loops. Below errors show in the log:

[19/08/2024, 12:33:28] [homebridge-magic-occupancy] Restarting Process...
[19/08/2024, 12:33:29] [homebridge-magic-occupancy] Launched child bridge with PID 531864
[19/08/2024, 12:33:29] Registering accessory 'homebridge-magic-occupancy.MagicOccupancy'
[19/08/2024, 12:33:30] [homebridge-magic-occupancy] Loaded homebridge-magic-occupancy v3.3.0 child bridge successfully with 5 accessories
HAP-NodeJS WARNING: The accessory 'homebridge-magic-occupancy' has an invalid 'Name' characteristic ('homebridge-magic-occupancy'). Please use only alphanumeric, space, and apostrophe characters. Ensure it starts and ends with an alphabetic or numeric character, and avoid emojis. This may prevent the accessory from being added in the Home App or cause unresponsiveness.
[19/08/2024, 12:33:30] Loaded 0 cached accessories from cachedAccessories.0EDD6B87BFA4.

/var/lib/homebridge/node_modules/homebridge-magic-occupancy/index.js:43
        Characteristic.call(
                       ^
TypeError: Class constructor Characteristic cannot be invoked without 'new'
    at new Characteristic.TimeoutDelay (/var/lib/homebridge/node_modules/homebridge-magic-occupancy/index.js:43:24)
    at OccupancySensor.addCharacteristic (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Service.ts:518:57)
    at new MagicOccupancy (/var/lib/homebridge/node_modules/homebridge-magic-occupancy/index.js:158:31)
    at ChildBridgeFork.startBridge (/var/lib/homebridge/node_modules/homebridge/src/childBridgeFork.ts:177:52)
[19/08/2024, 12:33:30] [homebridge-magic-occupancy] Child bridge process ended
[19/08/2024, 12:33:30] [homebridge-magic-occupancy] Process Ended. Code: 1, Signal: null
[19/08/2024, 12:33:37] [homebridge-magic-occupancy] Restarting Process...
[19/08/2024, 12:33:39] [homebridge-magic-occupancy] Launched child bridge with PID 531882
[19/08/2024, 12:33:39] Registering accessory 'homebridge-magic-occupancy.MagicOccupancy'
[19/08/2024, 12:33:39] [homebridge-magic-occupancy] Loaded homebridge-magic-occupancy v3.3.0 child bridge successfully with 5 accessories
HAP-NodeJS WARNING: The accessory 'homebridge-magic-occupancy' has an invalid 'Name' characteristic ('homebridge-magic-occupancy'). Please use only alphanumeric, space, and apostrophe characters. Ensure it starts and ends with an alphabetic or numeric character, and avoid emojis. This may prevent the accessory from being added in the Home App or cause unresponsiveness.
[19/08/2024, 12:33:39] Loaded 0 cached accessories from cachedAccessories.0EDD6B87BFA4.

/var/lib/homebridge/node_modules/homebridge-magic-occupancy/index.js:43
        Characteristic.call(
                       ^
TypeError: Class constructor Characteristic cannot be invoked without 'new'
    at new Characteristic.TimeoutDelay (/var/lib/homebridge/node_modules/homebridge-magic-occupancy/index.js:43:24)
    at OccupancySensor.addCharacteristic (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Service.ts:518:57)
    at new MagicOccupancy (/var/lib/homebridge/node_modules/homebridge-magic-occupancy/index.js:158:31)
    at ChildBridgeFork.startBridge (/var/lib/homebridge/node_modules/homebridge/src/childBridgeFork.ts:177:52)
[19/08/2024, 12:33:39] [homebridge-magic-occupancy] Child bridge process ended
[19/08/2024, 12:33:39] [homebridge-magic-occupancy] Process Ended. Code: 1, Signal: null
Jason-Morcos commented 2 months ago

If someone wants to take a stab opening a PR that adds v2 support, I'd be glad to review! Otherwise I'll take a look in a couple weeks when I have some bandwidth

pfrasun commented 2 weeks ago

Just as a reminder. Do you plan to do something about it?

Jason-Morcos commented 2 weeks ago

Thanks for the reminder! Turned out to require fairly substantial changes but the v4 version should support both Homebridge 1 and 2

pfrasun commented 2 weeks ago

Version 4 does work with HB2, but the plugin itself stopped working for me. Switches do not trigger occupancy sensor.

Jason-Morcos commented 2 weeks ago

Odd - it appears to be working for me @pfrasun are you running v1 or v2 of homebridge? Anything showing up in the logs that might be useful for debugging? Is it just specific types of switches that aren't working? Can you share the problematic config?

pfrasun commented 2 weeks ago

That is really strange. I tried in both configs:

There are no errors in logs related to the issue. Switch events are not shown it means the switch does not work. New installation did not solve it.

Jason-Morcos commented 2 weeks ago

Stateful switches shouldn't turn off the presence sensor unless the stay occupied delay is set to zero (otherwise they'll stay on after the switch flips off for the stay occupied delay duration). Have you tried reverting to 3.x to ensure it's behaving differently in v4 than it did in v3? If it's definitely borked, can you share the part of your config for the plugin so I can try to replicate your exact setup?

pfrasun commented 2 weeks ago

Yes, 3.3.0 works as intended. I use it with presence sensors having no delay, but also sensors with delay don’t work, I tried it.

Jason-Morcos commented 2 weeks ago

I think I figured it out and fully fixed in 4.0.1! I removed a previously-undocumented private service (basically home bridge HAP changes appear to make these kind of dynamic characteristics not as kosher anymore). Let me know if this solves it https://github.com/Jason-Morcos/homebridge-magic-occupancy/pull/52

pfrasun commented 2 weeks ago

Many thanks, it looks like it works this time.