zachowj / hass-node-red

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

Entities not getting proper name #114

Closed AlexHartog closed 2 years ago

AlexHartog commented 2 years ago

Version of the custom_component

1.0.6

Configuration

No custom configuration

Describe the bug

I've recently installed Node-RED Companion to be able to use the entity nodes.

Whenever I create a new entity node (type: switch) in Node Red, it gets created in Home Assistant as an entity. But it gets called switch.unnamed_device and switch.unnamed_device_2 etc.

If you check the debug logs below, it all seems to be received by Home Assistant though.

Do you know what could be going wrong here?

Debug log

2022-01-27 10:43:57 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140556853094336] Received {'type': 'nodered/discovery', 'server_id': '136c2d95.c8b952', 'node_id': 'bdb69cbdcb7103e1', 'component': 'switch', 'state': True, 'config': {'name': 'new_entity'}, 'id': 21}
2022-01-27 10:43:57 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140556853094336] Sending {'id': 21, 'type': 'result', 'success': True, 'result': {'success': True}}
2022-01-27 10:43:57 DEBUG (MainThread) [custom_components.nodered.discovery] Discovery message: {'type': 'nodered/discovery', 'server_id': '136c2d95.c8b952', 'node_id': 'bdb69cbdcb7103e1', 'component': 'switch', 'state': True, 'config': {'name': 'new_entity'}, 'id': 21}
2022-01-27 10:43:57 INFO (MainThread) [custom_components.nodered.discovery] Creating switch 136c2d95.c8b952 bdb69cbdcb7103e1
zachowj commented 2 years ago

The first time you deploy it is when HA creates the entity id for the entity. If you have the name property in the HA config section it will attempt to use that as the entity id. If it doesn't have a value the entity id will default to the id of the node, i.e. switch.12ab77d7a. After the first deployment of the node, the only way to change the entity id is through the HA UI.

Sanret281 commented 2 years ago

@Gotrah I had the same exact issue. Make sure you're running the latest versions of HA and NodeRed. That fixed it for me at least.

AlexHartog commented 2 years ago

Ah amazing! I found out due to another issue that my HASS OS was quite old. Not sure why, because I just installed it a couple of weeks ago. Will give this a try when I get home again. Thanks for that!

On Tue, 1 Feb 2022 at 23:39, Sanret281 @.***> wrote:

@Gotrah https://github.com/Gotrah I had the same exact issue. Make sure you're running the latest versions of HA and NodeRed. That fixed it for me at least.

— Reply to this email directly, view it on GitHub https://github.com/zachowj/hass-node-red/issues/114#issuecomment-1027357632, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2W7CPSLPCEQM3B64NMJDDUZBOK7ANCNFSM5M5MWHZQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

AlexHartog commented 2 years ago

Upgraded my Home Assistant Core and this solved all the issues. Thanks a lot!