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
151 stars 13 forks source link

Name is overwritten after restart homebridge #462

Open Nastras opened 1 year ago

Nastras commented 1 year ago

Plugin version

7.5.1

Plugin configuration

{ "bridge": { "name": "homebridge-securitysystem", "username": "", "port": , "pin": "", "manufacturer": "", "model": "Ak-SHS-2", "advertiser": "avahi", "bind": ["eth0"] },

"plugins": [ "homebridge-securitysystem" ],

"accessories": [ { "accessory": "security-system", "name": "Wh Alarmanlage", "default_mode": "off", "disabled_modes": ["Home"], "trip_switch_name": "Alarmsirene", "siren_switch": true, "siren_mode_switches": false, "override_off": true, "save_state": true, "test_mode": false, "arm_seconds": 0, "trigger_seconds": 0, "reset_minutes": 3, "reset_off": true, "command": true, "command_current_home": "", "command_current_away": "", "command_current_night": "", "command_current_off": "", "command_current_triggered":"" }, { "accessory": "security-system", "name": "Gr Alarmanlage", "default_mode": "off", "disabled_modes": ["Home"], "trip_switch_name": "Alarmsirene", "siren_switch": true, "siren_mode_switches": false, "override_off": true, "save_state": true, "test_mode": false, "arm_seconds": 0, "trigger_seconds": 0, "reset_minutes": 3, "reset_off": true, "command": true, "command_current_home": "", "command_current_away": "", "command_current_night": "", "command_current_off": "", "command_current_triggered":"" } ] }

Homebridge version

1.6.1

What's your question?

Hello @MiguelRipoll23

I have the following problem. The name of the switch alarm is overwritten in Homekit after each restart of the Homebridge to the value that is in the config.json. Do you have an idea where the problem is?

IMG_4556 IMG_0081 IMG_0082

MiguelRipoll23 commented 1 year ago

Hey there,

To fully understand the issue as I'm not familiar with the app you're using I've some questions:

I've seen issues happening with the configuration when multiple instances of the plugin are used like your case, you can also try to use a child bridge (a Homebridge feature) to prevent conflict between other instances.

Nastras commented 1 year ago

Hey @MiguelRipoll23 thanks for the quick answer 👌

Is the name issue related with the Security system's accessory? (Not the trip switch or other other switches exposed by the plugin) It is the device name of the alarm system. It is not a custom feature. If I change the name from "Wh Alarm System" to "Alarm System" in Homekit, this change resets after a restart of Homebridge. The app I used here is called HomeDash but the behavior is the same when I change it in the Eve app.

I've seen issues happening with the configuration when multiple instances of the plugin are used like your case, you can also try to use a child bridge (a Homebridge feature) to prevent conflict between other instances.

What error do you mean exactly? So far everything works as expected except that the name change is not applied.

If you say that it is better to use a second instance I can of course set that up?

Nastras commented 1 year ago

Here a screen from Eve App:

IMG_0084 IMG_0083

MiguelRipoll23 commented 1 year ago

I fully understand the issue you're having right now. Unfortunately changes to accessory names that are applied outside Homebridge like for example an iOS/macOS device won't be persisted.

The new name should be applied to the Homebridge configuration in order to avoid the name being reset. While it's possible to receive name changes coming from HomeKit it would add more complexity into the plugin.

With respect to the multiple instances issue,see #346 for example. It happens to other options mostly.

Nastras commented 1 year ago

I fully understand the issue you're having right now. Unfortunately changes to accessory names that are applied outside Homebridge like for example an iOS/macOS device won't be persisted. The new name should be applied to the Homebridge configuration in order to avoid the name being reset. While it's possible to receive name changes coming from HomeKit it would add more complexity into the plugin.

Good that you understand my question, but I understand your answer only partially 😅. Sorry.

So to summarize again:

I assign in the config.json a device name "name": "Wh Alarm", if I change this name in homekit to "Alarm" the name in homekit will be changed again to " Wh Alarm" after a restart of the homebridge.

With every other plugin homekit remembers the changed device name but not here. It looks like the plugin always reports the name from config.json to homekit again.

Can the behavior possibly be a bug that is solved by a second instance?

MiguelRipoll23 commented 1 year ago

I assign in the config.json a device name "name": "Wh Alarm", if I change this name in homekit to "Alarm" the name in homekit will be changed again to " Wh Alarm" after a restart of the homebridge.

This is the expected behaviour at the moment. When you change an accessory name an event is sent to Homebridge, if the plugin has implemented an event receiver for accessory name changes it can read the new name and persist it in a file. Although the name from the configuration will still be outdated.

The plugin doesn't have implemented at the moment the receiver neither the logic to handle this kind of event for the accessories exposed from the plugin.

With every other plugin homekit remembers the changed device name but not here. It looks like the plugin always reports the name from config.json to homekit again.

Could you provide me some plugin examples? Maybe if I find an easier way to implement this functionality it can land in an upcoming release.

Can the behavior possibly be a bug that is solved by a second instance?

Nope! It does happen with one instance as well.

Nastras commented 1 year ago

Could you provide me some plugin examples? Maybe if I find an easier way to implement this functionality it can land in an upcoming release.

https://github.com/ebaauw/homebridge-hue https://github.com/valiquette/homebridge-easee https://github.com/hans-1/homebridge-cmdtriggerswitch

This is the expected behaviour at the moment. When you change an accessory name an event is sent to Homebridge, if the plugin has implemented an event receiver for accessory name changes it can read the new name and persist it in a file. Although the name from the configuration will still be outdated. The plugin doesn't have implemented at the moment the receiver neither the logic to handle this kind of event for the accessories exposed from the plugin.

Thank you for the explanation 👍.

MiguelRipoll23 commented 1 year ago

Those plugins don’t have any kind of functionality to receive updated accessory names, probably depends on the HomeKit data from the device.

The reason it doesn’t work for the security system plugin is because it exposes an accessory instead of a platform and sub-accessories instead of a single accessory.

I will have to research on this one to see if something is possible to implement it easily.

Nastras commented 1 year ago

Sorry. I assumed it was available in one of the plugins. Thanks for your effort!

github-actions[bot] commented 5 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a few days if no further activity occurs. Thank you for your contributions.