jason0x43 / hacs-hubitat

A Hubitat integration for Home Assistant
MIT License
196 stars 48 forks source link

Entity Confusion with Multiple Hubitat Integrations #149

Closed chadisrad323 closed 2 years ago

chadisrad323 commented 2 years ago

I have two Hubitat Elevations integrated into Home Assistant. It works well except for the way entities are associated to devices. If a device on Hub A has the same device number as a device on Hub B, Home Assistant mixes the entities together and randomly shows the device name as either the Hub A or Hub B device. The unique identifier HA uses should be a combination of hub and device number, rather than just the device number. Please see attachment for screenshots and an explanation of the issue I'm experiencing. Otherwise, this integration is fantastic -- thanks for all your work.

HA Hubitat Device Confusion.pdf

jason0x43 commented 2 years ago

The unique ID is a combination of a hash of the Maker API token (which is unique per install of Maker API), the device number, and the entity type. Those should be unique per entity, even when devices on different hubs have the same number. But there certainly could be a bug in there somewhere.

Find two of the entities that are being mixed up in the entity registry (<config>/.storage/core.entity_registry). Their unique_id and device_id properties should be different. If they're not, well, that's a problem.

chadisrad323 commented 2 years ago

Thanks for the quick reply. I have attached the entries for the two entities. They do have different unique identifiers, but they have the same device_id, even though they are set up on two separate Hubitat hubs and separate devices. The only commonality between the two devices is they were each assigned device ID 33 by the respective Hubitat hubs.

core_entity_registry_examples.txt

yougotborked commented 2 years ago

I'm seeing the same issue here, Depending on the order I "Reload" the integration (2 hubs, 1 focused on zibgee, 1 zwave) The "last" device's reloading supersedes the previous.

summitbri commented 2 years ago

I am about to add a second hubitat to HA. Is there anything I can do to Hubitat #2 in advance to avoid a problem?

yougotborked commented 2 years ago

From my understanding of the issue, if you make sure all your device IDs (number at the end of the hubitat device URL) are unique across 2 hubs, that would fix it

summitbri commented 2 years ago

So after some inspection I've discovered multiple devices, mostly Zwave, that have conflicting device IDs. Am I able to change these on one hubitat without causing chaos in my system?

jason0x43 commented 2 years ago

I don't believe you can update device IDs on Hubitat (well, other than by removing and re-adding a device). The integration needs to be updated to ensure that devices coming from different hubs have different IDs (which I'll hopefully get to soon).

AlohaFlyer commented 2 years ago

Any updates on this? I am still experiencing this bug. I am running 4 Hubitat hubs with this integration.

Thank you for this integration. I appreciate your work.

jason0x43 commented 2 years ago

Not yet, but I’ll try to take a look this week.

chadisrad323 commented 2 years ago

Thank you, @jason0x43. This will be hugely helpful to those of us with multiple hubs!

jason0x43 commented 2 years ago

I can reproduce the issue on my test system, so that's something.

jason0x43 commented 2 years ago

Progress! I see why unique devices weren't being created for each hub, and how to fix that. Now to figure out a way to cleanly update an installation...

AlohaFlyer commented 2 years ago

Fantastic! I am running 4 HE hubs. Looking forward to testing this. Thank you

jason0x43 commented 2 years ago

I just published a new prerelease. This version will create new device entries with unique IDs for everything, but the entity IDs should all be the same. Assuming this works properly outside of my test environment, I'll look into automatically cleaning up leftover devices (right now I've just made it easier to manually clean those up).

AlohaFlyer commented 2 years ago

Awesome I will give it a go and report back.

AlohaFlyer commented 2 years ago

Ok I have loaded the new prerelease update, all appears to be working great.

I did decide to remove the hubitat hubs from HA, and then re-add them.

chadisrad323 commented 2 years ago

This is fantastic news. I'm not sure how to load beta code but looking forward to implementing it soon.

jason0x43 commented 2 years ago

I published another beta release for this (0.7.2b2). This release fixes an issue with the updated device identifiers, and it automatically migrates devices to use the new identifiers (so it shouldn't break existing automations, assuming automations weren't using ambiguous devices).

To load beta releases in HACS:

  1. Open HACS in HA
  2. Click "Integrations"
  3. Click the 3-dot menu button on the Hubitat integration and choose "Redownload"
  4. Enable the "Show beta versions" toggle

Beta versions should show up. You may also need to click "Update information" from the integration menu (the same menu that had "Redownload").

chadisrad323 commented 2 years ago

I have installed this and so far it's working great. Thank you!

On Tue, May 31, 2022 at 8:09 PM Jason Cheatham @.***> wrote:

I published another beta release for this (0.7.2b2). This release fixes an issue with the updated device identifiers, and it automatically migrates devices to use the new identifiers (so it shouldn't break existing automations, assuming automations weren't using ambiguous devices).

To load beta releases in HACS:

  1. Open HACS in HA
  2. Click "Integrations"
  3. Click the 3-dot menu button on the Hubitat integration and choose "Redownload"
  4. Enable the "Show beta versions" toggle

Beta versions should show up. You may also need to click "Update information" from the integration menu (the same menu that had "Redownload").

— Reply to this email directly, view it on GitHub https://github.com/jason0x43/hacs-hubitat/issues/149#issuecomment-1143069690, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATWZYG2Z6EFK2LGCGOWGD53VM3H6LANCNFSM5HOUD53A . You are receiving this because you authored the thread.Message ID: @.***>

AlohaFlyer commented 2 years ago

Works great! Thank you for the update.

jason0x43 commented 2 years ago

There was a bug in 0.7.2b2 that would break device triggers. If you've run into any issues with those, you can try 0.7.2b4. That version also cleans up a leftover dummy device that was created by b2.

AlohaFlyer commented 2 years ago

I had 0.7.2b2 and decided to try 0.7.2b4. But it broke my install. All 4 of my hubitats couldn't connect anymore. So I rolled it back to 0.7.2b2 and re-added them. I'm back up and running. I should have screenshot'd the problem but missed my chance.

yougotborked commented 2 years ago

I had a similar issue. Captured it here

This error originated from a custom integration.

Logger: homeassistant.config_entries
Source: custom_components/hubitat/hub.py:522
Integration: Hubitat (documentation, issues)
First occurred: 8:40:07 AM (2 occurrences)
Last logged: 8:40:07 AM

Error setting up entry Hubitat zigbee for hubitat
Error setting up entry Hubitat Zwave for hubitat
Traceback (most recent call last):
  File "/config/custom_components/hubitat/hub.py", line 517, in _update_device_ids
    int(id_set[1])
ValueError: invalid literal for int() with base 10: '6ccc5096'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 339, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/hubitat/__init__.py", line 37, in async_setup_entry
    if not await hub.async_setup():
  File "/config/custom_components/hubitat/hub.py", line 292, in async_setup
    _update_device_ids(self.id, self.hass)
  File "/config/custom_components/hubitat/hub.py", line 522, in _update_device_ids
    dev_id = id_set[1].split(":")[1]
IndexError: list index out of range
jason0x43 commented 2 years ago

Thanks for the error log! I think I see what's happening; the identifier update code isn't handling multiple hub IDs properly. I should have an update out shortly.

jason0x43 commented 2 years ago

I just published v0.7.2b5 which should take care of that issue.

yougotborked commented 2 years ago

V5 looks good. No error. thanks

AlohaFlyer commented 2 years ago

v0.7.2b5 seems to be working great for me and my 4 Hubitat hubs. Thank you for the quick fix. 😎

jason0x43 commented 2 years ago

Resolved in release 0.7.2.

AlohaFlyer commented 2 years ago

Thank you for the fix 🙏