I’d like to set up node red to deliver emails to send out when a pump is being triggered, however I’d like sensor values to be present, and thought something like this may do it (function node):
{
node.send({
topic: "Subject: Front Pump Active...",
payload: "Rain fall today: " + sensor.netatmo_thermostat_indoor_rain_rain + " Water Level: " + sensor.water_tank_level,
});
}
return;
if anyone can help with the above, that would be amazing,
You can’t just use sensor.something in NodeRed. It is a HA notation style.
In NodeRed normally have to request sensor states by using Current State nodes and then send that along with the messages in the flow.
However there is a trick, since all states in HA is stored in global variable too.
You can can view the global variable by opening the Context Data (stacked discs) sidebar from the upper right menu and then click the refresh icon to the right of the Global headline.
The values in there can be retrieved with the global.get command.
{
node.send({
topic: "Subject: Front Pump Active...",
payload: "Rain fall today: " + global.get('homeassistant').homeAssistant.states["sensor.netatmo_thermostat_indoor_rain_rain"] + " Water Level: " + global.get('homeassistant').homeAssistant.states["sensor.water_tank_level"],
});
}
return;
The object word just means you have not extracted a single value, but rather a bunch of values and it have no way of showing that, so you need to correct you path.
Open the Context Data and update the global section as describe earlier.
Now you should see the data and you can follow the path in the global.get command down the hierarchy to the data you want. You might have to put more .something or [x] behind the command to reach the value you want.
If it goes wrong then post a picture of the sensor in the Context Data here and we can help to adjust the line.