MiguelRipoll23 / homebridge-securitysystem

Homebridge plugin that creates a security system accessory that can be triggered by HomeKit sensors.
https://www.npmjs.com/package/homebridge-securitysystem
MIT License
152 stars 13 forks source link

Trip / Siren Mode Switches *Bug* #583

Open ohhmyjawwsh opened 4 months ago

ohhmyjawwsh commented 4 months ago

Plugin version

8.3.0

Plugin configuration

{ "name": "Security System", "serial_number": "S3CUR1TYSYST3M", "default_mode": "Home", "arm_seconds": 0, "trigger_seconds": 0, "reset_minutes": 1, "save_state": true, "proxy_mode": false, "test_mode": false, "trip_switch_name": "Siren", "trip_override_switch_name": "Panic", "mode_home_switch_name": "Mode Home", "mode_away_switch_name": "Mode Away", "mode_night_switch_name": "Mode Night", "mode_off_switch_name": "Mode Off", "mode_away_extended_switch_name": "Mode Away Extended", "mode_pause_switch_name": "Mode Pause", "audio_switch_name": "Audio", "override_off": true, "reset_off_flow": true, "double_knock": false, "double_knock_seconds": 90, "arming_sensor": false, "tripped_sensor": false, "tripped_sensor_seconds": 5, "triggered_sensor": false, "triggered_sensor_seconds": 5, "reset_sensor": false, "mode_switches": true, "mode_off_switch": true, "mode_away_extended_switch": false, "mode_pause_switch": false, "pause_minutes": 0, "arming_lock_switch": false, "arming_lock_switches": false, "trip_switch": true, "trip_override_switch": false, "trip_mode_switches": false, "siren_mode_switches": false, "audio_switch": false, "audio": false, "audio_language": "en-US", "audio_volume": "100", "audio_arming_looped": false, "audio_alert_looped": false, "_bridge": { "name": "Security System", "username": "0E:82:89:ED:69:C9", "port": 51895 }, "accessory": "security-system" }, { "name": "Storage Unit Security System", "serial_number": "S3CUR1TYSYST3M2", "default_mode": "Away", "arm_seconds": 0, "trigger_seconds": 0, "reset_minutes": 10, "save_state": true, "proxy_mode": false, "test_mode": false, "trip_switch_name": "Siren", "trip_override_switch_name": "Panic", "mode_home_switch_name": "Mode Home", "mode_away_switch_name": "Mode Away", "mode_night_switch_name": "Mode Night", "mode_off_switch_name": "Mode Off", "mode_away_extended_switch_name": "Mode Away Extended", "mode_pause_switch_name": "Mode Pause", "audio_switch_name": "Audio", "override_off": true, "reset_off_flow": true, "double_knock": false, "double_knock_seconds": 90, "disabled_modes": [ "Night" ], "arming_sensor": false, "tripped_sensor": false, "tripped_sensor_seconds": 5, "triggered_sensor": false, "triggered_sensor_seconds": 5, "reset_sensor": false, "mode_switches": true, "mode_off_switch": true, "mode_away_extended_switch": false, "mode_pause_switch": false, "pause_minutes": 0, "arming_lock_switch": false, "arming_lock_switches": false, "trip_switch": true, "trip_override_switch": false, "trip_mode_switches": false, "siren_mode_switches": false, "audio_switch": false, "audio": false, "audio_language": "en-US", "audio_volume": "100", "audio_arming_looped": false, "audio_alert_looped": false, "_bridge": { "username": "0E:42:BC:C2:E8:14", "port": 34090 }, "accessory": "security-system" }

Homebridge version

1.8.4

What happened?

When “Show Trip Mode Switches” is not check marked, the trip mode switches still appear in HomeKit. This was apparent for both iterations of security systems I have setup within the plugin. This also only became an issue after the latest update.

After reading through some old issues that were closed already, I came across one where you talked about the JSON field names being fixed in the next (latest) version. Unfortunately, while they may have been changed, it did not fix application of this option being checked or unchecked, because

"trip_mode_switches": false

does not make any impact on what’s exposed in HomeKit. All switches were still exposed.

The workaround I found - as seen in my configuration provided above - is to add

"siren_mode_switches": false

back into the JSON config below the boolean being set for trip mode switches. For now, this was an easy fix & successfully removed the switches I did not need or want. However, it looks like this will need to be addressed in the source code on the next release if possible since it appears to be a bug within the changes made. I hope this help you & anyone else you may read this before a fix is implemented.

Thank you for your amazing plugin! I could not imagine my HomeKit setup without it! 🙌🏼

Relevant log output

No response

ohhmyjawwsh commented 4 months ago

Update: Even with my workaround still in place, the switches remain visible inside third party apps such as Controller for HomeKit, even though they remain hidden within the Home app. (Multiple child bridge & Homebridge reboots have been performed but no correction seen. When saving changes in the plugin's configuration UI, it removes my workaround so I have to add it back within the JSON editor.)

Additionally, the Siren switch still appears even when I have it selected not to be shown in the configuration, & neither the siren or the panic switch can be used as start events within Controller; it returns "Invalid Parameter", but this was never an issue before. (The panic siren you see in the screenshot inside the automation is a separate outlet siren unrelated to the plugin.) Unsure of suggestions to help with this one but wanted to let you know since it is likely all connected. image image

MiguelRipoll23 commented 4 months ago

Sorry about that, I'll will take a look to see what's going on and report back soon. Thanks for reporting the issue.

ohhmyjawwsh commented 4 months ago

No problem! These things happen lol. Hope all of this helps you narrow it down a little easier. Thank you again!

MiguelRipoll23 commented 4 months ago

Bug has been fixed in the beta channel, will be available to the general public soon. Thanks!

ohhmyjawwsh commented 4 months ago

Excellent, thank you so much! You rock. 🤘🏼

MiguelRipoll23 commented 4 months ago

Fix is now in the stable channel, thanks for reporting.

ohhmyjawwsh commented 2 months ago

@MiguelRipoll23 Hello! I just wanted to report back on this issue. We may need to re-open it.. I still unfortunately see switches show up in HomeKit that have been deactivated in the plugin settings. More so the switches than the modes, but sometimes both, and my understanding is that the switches are tied to activated modes as well - such as the Trip Away / Trip Night switches, etc.

It seems to happen whenever the child bridge is restarted, Homebridge is restarted, or after updates to the plugin are installed. What's weird is that it does not happen every time a reboot happens either, but often enough it is an apparent bug somewhere. What's most frustrating is I can't tell if the switches are being cached somewhere in the memory of the HomePods/Apple TV's running as bridges, or within Homebridge, or within the plugin somehow.

I've found that when I re-enable the switches / modes I've chosen to hide, reboot and let the plugin start up again, then go in and hide/deactivate the modes again before another bridge/child bridge reboot, the switches and modes will disappear as expected from within the HomeKit Home app and everything will appear to be in perfect working order. But then I will reboot Homebridge, the child bridge, or when I installed the last couple of plugin updates, it would all show back up in the Home app with "No Response" on the switches.

I have so many automations that include switches from this plugin that can't be backed up within the Controller for HomeKit app since they're not in a scene and that's a limitation in HomeKit with 3rd party apps, or else I would completely delete the plugin and config, then reinstall and set it all up again to see if that would fix it. But I'm really trying to avoid doing that given my situation with all the things I can't backup and restore..

Is there any way you know of that I can help check/troubleshoot with you to see if this is a bug within the plugin that you may be able to fix or if it's a cache error within my setup which will truly require an uninstall/re-setup? Any help would be greatly appreciated. If you couldn't tell already, I'm forever grateful for this plugin lol.

Side note/issue: I have selected the option for the mode state to persist between reboots, however, whenever the child bridge or Homebridge reboots, both of the iterations I have setup (one for my apartment, one for the storage unit) will reset to "Home" mode, no matter what other mode they are set to before reboot. I've seen this issue brought up before and you've pushed fixes for it, so I thought I'd let you know -- and maybe it's related to the above issues I'm having with the switches?

MiguelRipoll23 commented 1 month ago

I'll try to get back to this soon, currently busier than usual at work

ohhmyjawwsh commented 1 month ago

No worries at all! With the iOS 18 software update and the ability to choose your primary hub in HomeKit now, I've been playing around with it trying to narrow down if it's a hub issue or a plugin issue and I still can't tell unfortunately. The ghost switches will disappear sometimes when I switch to a different Apple TV as the hub, but then when I switch away and back to that same hub another day, they will still come back or be there. I think it really has something to do with the switches getting cached somewhere along the line between Homebridge and HomeKit but without deleting everything and starting it over I just can't tell. When you have time to look into it a bit more, just let me know if there's anything I can do to help troubleshoot or give logs, etc. Thank you again!

ohhmyjawwsh commented 1 week ago

@MiguelRipoll23 I think I've figured out the reason why the default mode is forgotten sometimes upon plugin or Homebridge reboot:

I have 2 systems setup within the plugin (separate child bridges setup too). 1 has a default of Home, the other has a default of Away. When updating to the latest version you recently released, it required a plugin restart & I watched the logs as it boot back up. The logs show it found the default state of Home, and saved state was found to be restored. Sure enough, when I went back into Home app to check, both systems had been set to Home when prior to the reboot only one of them was set to that.

It seems when getting saved or default states, it locates the values for the primary or first instance set up, and ignores the values of the second, therefore overriding the second systems's chosen settings, and updating all instances to the settings of the first.

Here's a screenshot of the logs immediately upon reboot, and in the second one you can see where I had to manually switch the storage unit system back to Away. After the reboot, it shows the saved state of the storage unit system was found and restore to Home, but I did confirm before the update/reboot that it was set to Away, so it may simply just not be properly saving the current state for the additional systems before reboot.

image

image

MiguelRipoll23 commented 1 week ago

Stay tuned, maybe I can fix it by making the persistence filename unique by appending the serial number.

MiguelRipoll23 commented 1 week ago

I just released an update to the beta channel, hopefully bug is fixed now

ohhmyjawwsh commented 1 week ago

So far so good!! I've updated to the beta, thankfully it wasn't actually a breaking change for my setup & didn't lose anything lol but as far as the current/cached state being retained upon update and reboots, I've now tested it with multiple reboots between the plugin, the individual child bridges for each instance, and Homebridge as a whole and every time it retained whichever state I set it to beforehand. WOO! Great thinking, and thank you! I'll circle back if that changes but I think that's all fixed now.

Unfortunately it did not however prevent the ghost trip switches showing back up for options I've disabled in the plugin settings. They appear and disappear randomly when switching between HomeKit hubs as well. Still not sure what to suggest for that other than deleting everything and starting fresh to see if it stays a problem with a fresh install. Any ideas I could help test/try outside of that?

ohhmyjawwsh commented 1 week ago

I think it's a caching issue with the HomeKit hubs. Just setup a test home and added a test security system instance. I've disabled and enabled switches and modes with reboots in between, but I can't reproduce the issue in the test home which does not have a HomeKit hub setup for it since I don't have any extras. I guess it could be a caching issue within Homebridge too but I've made sure all unused or outdated cached devices and child bridges/hubs are deleted from within the Homebridge settings.