zachowj / hass-node-red

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

Sensor state remains `unknown` #205

Closed philipp-luettecke closed 1 year ago

philipp-luettecke commented 1 year ago

Version of the custom_component

Node Red Companion v2.1.1

Configuration

Configured via UI and created sensors are detected properly.

obsolete

Describe the bug

The state of a created sensor remains unknown even though everything else between HA and Node Red seems to work just as expected. The event seems to reach the HA integration (see logs below), but apparently it does not seem to be handled by Home Assistant.

I also have a "Button" configured, that is working just fine. All button press events are passed to Node Red.

Debug log


2023-08-08 11:02:10.189 DEBUG (MainThread) [custom_components.nodered] Entity Update: {'type': 'nodered/entity', 'server_id': '935bec4f.a6043', 'node_id': 'ab9e5a8076117fc9', 'state': 'done', 'attributes': {}, 'id': 44}
2023-08-08 11:06:09.877 DEBUG (MainThread) [custom_components.nodered] Entity Update: {'type': 'nodered/entity', 'server_id': '935bec4f.a6043', 'node_id': 'ab9e5a8076117fc9', 'state': 'on', 'attributes': {}, 'id': 45}
philipp-luettecke commented 1 year ago

Found the issue.

It was about the state class setting in the Config Node. You shall not set it to measurement when writing string values as states.

So it was my fault :)

Great integration by the way 🥇