TimeZone issues with Node-Red addon in HA

Hi,

I’m running HA onder Proxmox on a NUC.
Since last night (after change to wintertime), my node-red addon is running 1 hr behind.
HA shows the local time (Amsterdam : GMT+1) which is okay but NR is now 1 hr behind and this is not okay.
I would expect the NR time is taken from the HA time but this doesn’t seem to be the case. Is there a way to set the NR time so everything is in phase again?

PSBefore the change, all was working fine!

Any help greatly appreciated!

Meanwhile I found a topic where the TZ can be changed in settings.js, unfortunately this did not work :frowning:

-ben

As far as I understand this stuff, Node-RED does not keep time as such. Time-aware nodes that want the time may go to the machine for the current time, and to locales for the timezone / offset from UTC, via JavaScript or Python.

Just to be clear, the Node-RED editor (as opposed to the program that runs the flows) runs in JavaScript inside a browser, and things like the Debug node will use the browser machine/locales setting (which may be different to Home Assistant, and also to Node-RED if they are each on a different machine).

Node-RED does hold an environment variable, where set, for the timezone. This is ‘TZ’ and if required has to be set somewhere in the startup sequence.

For free-standing Node-RED (eg run a Raspberry Pi) no environmental variables are set, so if required the TZ has to be added into the settings.js file. I believe that this is done by adding a line something like

process.env.TZ = "Europe/London";

to the file. The timezone string has to be one from the official list.

Where NR is an HA add-on, the settings file is specially modified with several settings not be used/read, and this approach may not work since this env variable is probably also set elsewhere.

For docker containers, the environment variable has to be set when the container is started. When NR is run as an HA add-on, supervised, the TZ environment variable is set in the add-on container by the supervisor, copied from Home Assistant settings.

If you have a free-standing container, then apparently the container startup should include the TZ

docker run -e TZ=Europe/London -p 1880:1880 nodered/node-red:latest

https://discourse.nodered.org/t/set-system-timezone-from-node-red/97809/7

As a starting point, it is always very easy to drop an inject node into any flow, and to set msg.payload to $ (env variable) TZ and see what this is set to, if anything.

It is also possible to set environment variables at the flow level. Just double click the flow name tab, go to the env list, and add TZ with your setting. I use this to help with testing some of my flows against different time zones.

If you are indeed running NR as HA add-on supervised, then perhaps a full machine reboot is required? I have not experienced any issues at any of the DST time changes over the past four years of running HA and Node-RED.

Hope this helps…