Hi everybody, hope you all are doing fine.
I have a strange behaviour in my nodered flow when using the global variable homeassistant and function node. Whenever I change something in the flow, I get an empty homeassistant global variable. I need to refresh the global variables in de IDE and then everything works.
This is the code in the function node:
var ha = global.get('homeassistant.homeAssistant'); energy = ha.states["sensor.solarpanel_energy_today"].state;
Then I run the code and I get this error:
TypeError: Cannot read property 'state' of undefined
When I debug the ha object, it is structured with no info (array of states is empty).
Then I refresh the global variables and all is well. I get my energy info.
The purpose is to generate a daily report based on states of multiple entities.
Is this a bug?
It is managed now (i update the globals after a change, once it is ok and nothing changes the flow works). Is the a workaroud (eg scripting the globals refresh)?
I’m on the latest HA (core-2021.7.3) and NR (9.2.1) on a raspberry pi.