if (nodes[3].attributes[0].current_value === 0)
{
return{payload: msg.payload.nodes[3].attributes[0].current_value}
}```
And that's the output I get on the debug node:
> ReferenceError: nodes is not defined (line 1, col 1)
@knolleary - Can u maybe help me with one more simple request. I´m trying to check the status of a flow variable in a function node but somehow the result is always "false" even if the actual status is true...
I'm using the node red with home assistant. Most HA paths have quotation marks "" that when entered gives me an error. Is there a way to mitigate the paths quotation marks?
Expected ')' and instead saw 'sensor'
var value = global.get("homeAssistant.states["sensor.flue_temp"].state");
msg.payload = value;
return msg;
"ReferenceError: sensor is not defined (line 1, col 50)"
I'm not sure what you mean by "contents of your global context or this flue_temp value ".
homeAssistant.states["sensor.flue_temp"].state that is from copy path button. Context storage is enabled in settings.js and a screenshot from my context tab under the global heading
Unfortunately I'm still not able to get a value. It almost seems that this data, the naming scheme, wasn't meant to be used like this. I don't need this particular value, I was just getting familiar with storing and recalling context, which I am able to do just not these HA values.
I'm pretty sure the nodes provided by home assistant will let me extract it. That said if you have other ideas I'd be glad to try them.
To get a property of a msg you use the copy path path button.
There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.
Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.
To access the global items in your screen shot, you can use the copy path button on the item or the sub item. I looked a bit closer at your screenshot & believe this should work...
var ha = global.get("homeassistant");
var value = ha.homeAssistant.states["sensor.flue_temp"].state;
msg.payload = value;
return msg;
Or...
var value = global.get('homeassistant.homeAssistant.states["sensor.flue_temp"].state');
msg.payload = value;
return msg;
But I can't be 100% sure as your picture doesn't show the full object. As I said, use the copy path button.
That is it, that is what I get from copy path. But the both of the 2 new examples work perfectly. Thank you this helpful. I'll use these values more often than globals I set, which in turn will give me more opportunities to use context.