mag1024 / bosch-alarm-homeassistant

Integration for Bosch Alarm panels that use the mode2 protocol: Solution, B/G series, AMAX
26 stars 4 forks source link

Fix issues with unique IDs #22

Closed sanjay900 closed 1 year ago

sanjay900 commented 1 year ago

Closes https://github.com/mag1024/bosch-alarm-homeassistant/issues/21

When generating unique ids for the entities, use the config entry id if the serial number is not available

Also, don't treat the panels model as a identifier, someone may have more than one panel with the same model!

sanjay900 commented 1 year ago

image

mag1024 commented 1 year ago

This is somewhat hacky, but what if we just wrote the entry_id into panel.serial_number (if empty) in __init__'s setup() -- before doing async_forward_entry_setups? It would get rid of a bunch of this extra plumbing -- which we'd otherwise need to do even more of, because the panel model we're removing from the device info should probably be replaced with entry_id as well, otherwise won't all the instances of the integration end up sharing the device?

sanjay900 commented 1 year ago

Yeah okay lets do that, looking at it now after restarting home assistant my two devices got linked back up, so that is def required

sanjay900 commented 1 year ago

I noted that it left behind an old device after all that, so ive added the necessary code to clean that device up as well.