jason0x43 / hacs-hubitat

A Hubitat integration for Home Assistant
MIT License
189 stars 46 forks source link

Integrations adds Contact or Switch to device names #240

Closed HomeWiseAdmin closed 6 months ago

HomeWiseAdmin commented 6 months ago

With the recent update the integration automatically adds _switch and _contact to the device name and ignores the original names. This messes up all the dashboards and renders buttons disabled due to the underlaying device suddenly changes after updates.

This is specially true with virtual devices that exhibits multiple devices (namely contact & switch), so basically the integration creates 2 new devices with prefix binary-contact & Switch and additionally adds the _Contact and _Switch to the end of each device (and ignores the already existing device with the original Hubitat name) .

This needs to be fixed and please do not change the device name in the future. Thank you Snapshot-001-0102-220259

HomeWiseAdmin commented 6 months ago

The update 0.9.17 actually make it worse and does not help in restoring the issues with the button names it changed few lights back to switches and rendered the light buttons useless. The best option is just to maintain the original names given in Hubitat also for consistency reasons, for devices with dual/multiple functions I guess it is better to use the "Status attribute for Devices/Rooms" from Hubitat as the default type. Thanks you for all your efforts otherwise a very good integration. Also it does not delete old devices, but I believe it is the HA and not this integration.

HomeWiseAdmin commented 6 months ago

I had to restore the backup to version 0.9.9 until this issue is resolved as otherwise many lights, buttons and virtual contacts needs to be changed and within the code as well, which is not practical. Thank you

jason0x43 commented 6 months ago

During some recent internal refactoring, the naming convention for switch entities, and for some entity unique IDs, was inadvertently changed. This led to _switch being appended to switch entity names, and to the unique ids for some entities (including switches) to be changed. For example, switch.bedroom was changed to switch.bedroom_switch. Note that the entity names displayed in Home Assistant were not changed; rather, new entities with different names were created.

v0.9.16 fixed the naming issue for switch entities, and v0.9.17 corrected the issue with unique entity IDs. In local testing, v0.9.8 (the release that's been out for the last few months) and and v0.9.17 generate the same unique entity IDs and entity names, at least for the devices in my local environment (a switch, contact sensor, various types of light, acceleration sensor, temperature sensor, and thermostat).

If you upgraded from 0.9.8 (or 0.9.9) to 0.9.17, everything should be fine, at least as far as which entities exist and how they're named. However, upgrading through the intermediate versions will result in some duplicate entities being created, and these aren't currently automatically removed when upgrading to 0.9.17.

Hopefully things are resolved at this point, but if not, please comment in one of the existing issues (#234, #235, #236) or open a new issue describing the specific problem you're seeing.

jason0x43 commented 6 months ago

After reviewing the original post and looking more into this, I still think this is a duplicate of #234, which appears to describe the issue you're seeing. It also describes what happens when upgrading to 0.9.17 (i.e., newly created entities from <0.9.17 aren't automatically deleted). The problem is specifically with switches; specifically, Switch was added to the end of switch names for versions 0.9.12-0.9.15, which caused switch entities to be created with an extra _switch appended to the name. This issue was fixed in v0.9.16.

A separate issue caused entity unique IDs to be generated differently in v0.9.12-0.9.16. This meant that even after switch entity names were fixed in 0.9.16, the integration still wasn't reverting to pre-existing entities (it was using newly created ones). This issue was fixed in v0.9.17.

As mentioned in #234, after updating to 0.9.17 the integration will go back to using entities created in versions before v0.9.12. However, it won't automatically delete any newly created entities. So even though the integration should be the correct entities, the old ones will still be there, just marked as "unavailable".

Note that the issue with misnamed entities was only confined to switches. Sensors do have the attribute added to their names, and always have. A contact sensor entity for a device named "Virtual Contact Sensor" will be named "Virtual Contact Sensor Contact". This is because some devices have multiple sensors, and you can't have repeated entity names. If you had a multi-sensor device named "Outdoor Multisensor" with illumination, acceleration, and temperature sensors, the various sensor entities can't all be named sensor.outdoor_multi_sensor.

If you're still seeing problems, you'll need to provide some concrete details about what you're seeing. Something like "The update 0.9.17 actually make it worse and does not help in restoring the issues with the button names it changed few lights back to switches and rendered the light buttons useless." doesn't provide enough information for me to diagnose the issue. 🙂

HomeWiseAdmin commented 6 months ago

Thanks for looking into it, if you need early testers when you do major updates, let us know we can create a test environment for this and hep you out.

HomeWiseAdmin commented 6 months ago

And you are right sorry, please disregards the comment that the update made it worse, it was written in frustration as most devices and automations didn't work. We thank you for all your efforts and I am sure this is shared feeling by all users of this integration. Happy new year

jason0x43 commented 6 months ago

I can understand your frustration, and I apologize for pushing out such a disruptive update (well, set of updates). Hopefully improved tests (working on those) and pre-releases will help avoid this kind of thing in the future.

jason0x43 commented 6 months ago

I'm closing this because it sounds like it's resolved, but if there are still issues we can reopen it.