zachowj / hass-node-red

Companion Component for node-red-contrib-home-assistant-websocket to help integrate Node-RED with Home Assistant Core
MIT License
446 stars 180 forks source link

Exposed Entities Rename After Each NodeRED Reboot #126

Closed sbach89 closed 2 years ago

sbach89 commented 2 years ago

Home Assistant 2022.2.9 NodeRED 11.0.4 NodeRED Companion 1.0.6

Everytime NodeRED restarts, for whatever reason, be it an update, or host reboot, exposed entities get duplicated with a _2 at the end, and the original entity is no longer available. Example, I have a switch called 'switch.scene_bedtime'. HA shows this as 'switch.scene_bedtime'. When NodeRED reboots, HA will create a new entity called 'switch.scene_bedtime_2'. If I restart the host, NodeRED, or reload NodeRED Companion, it sometimes corrects and the original entity is available and the new '_2' entity is no longer available.

Any clue what's going on here? Thanks!

sbach89 commented 2 years ago

Platform nodered does not generate unique IDs. ID nodered-2251a7d6.97aa98-41c3ad14ff4b0574 already exists - ignoring switch.scene_bedtime_2

zachowj commented 2 years ago

The node that is exposed to HA is it in a subflow?

sbach89 commented 2 years ago

No it is not

zachowj commented 2 years ago

Try

  1. unload the companion integration
  2. reboot HA
  3. remove all the entities that are associated with the exposed node
  4. reboot HA
  5. add back the integration
  6. check to see if a entity was created with the correct id minus the _2
  7. restart NR
  8. check if it created a new entity in HA or used the correct one
sbach89 commented 2 years ago

That seems to have taken care of it, thank you.