Creating a sensor from Node Red in Home Assistant

If you are creating and manipulating data in NodeRed then at some point you are going to want to add that data to your Home Assistant dashboard. This is remarkably simple to do although when you first look at the configuration it looks overly complicated. To do this I will use an example from my HA propject to control each room independently via the TRVs on each radiator.

To do this I created a chart to record the room temperature vs the heating thermostat temperature. With the system setup using NodeRed to control the temperature setting of each radiator I wanted to display this on the dashboard graphs I had created. The radiator temperature was set from a NodeRed flow so it was a simple matter of creating a sensor node to be able to chart this value in my dashboard. This can be seen in the following graph where Bedroom Setpoint is the output from my new sensor node.

To do this there is an action node Set Bedroom target temp that sets the thermostat temperature to msg.payload. It is this value that needs to be recorded via a sensor Bedroom Setpoint:

Add your new sensor node to the page and double click on it to open it.

Next we need to give it a name. This is the name that will show on your NodeRed flow. In my case I have called this Bedroom Setpoint.

Once you have done this click on the + symbol to the right of Entity config

Now give it the name that will be used in Home Assistant in the Name box and give it a Friendly Name.

Set Server to Home Assistant

Set State class to measurement. In this case we are simply recording the measurement. And because this is a temperature measurement I can use one of the pre-defined values for Device class and Unit of measurement. For simple numbers leave these last two blank. Then click on Update and you should have the following (make sure your new Entity config is set as below.

Then quite simply deploy your flow and after a few minutes your new sensor should start showing data. Make sure to setup your sensor in this order fully before you deploy it or you may need to restart Home Assistant or re-enter the settings for it to work correctly.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top