I’m in desperate need of some help and hoping someone here has some ideas (or more than someone).
All of my times in Node Red are off by 4hrs.
Here’s the deal; I currently have Docker on a Synology running Portainer, Hass.io, and Node Red (as an addon). I have also tried this with Node Red as its own stand alone container.
All three of those have a time zone variable added to them. My whole system worked fine a few days before my Hass.io crashed. I finally got everything back up and did a restore & wipe from a snapshot.
The only thing I can think is Docker is somehow on it’s own time zone. I can’t figure out how to give it a time zone variable because it is downloaded via the install package and I can’t find any command line for an install.
I have spent the last 3 days on this and can’t find an answer.
If you install the NodeRed via the addon, simply go to your home assistant config folder, open the node-red folder and edit your timezone in the settings.js.
i.e. like this:
process.env.TZ = “Europe/Brussels”;
Have the same problem, could you pls explain where exactly the time zone information should be set. Tried above in the settings.js but did get an failure.
Thank you - Dave
I have the same issue and have tried to add the fix line in the settings.js as mentionned in previous posts: process.env.TZ = "America/Toronto";
(that time zone is actually what I need)
This did not fix it for me.
One thing I noted while looking at the log is this: 7 Nov 09:59:35 - [info] Settings file : /etc/node-red/config.js
I used the terminal to go look for this location for the config.js file but there is no /etc/node-red folder at all. I even tried creating the config.js file in a new /etc/node-red folder with the TZ line in there but that didn’t work either.
I do restart Node-RED add-on before each try.
I am using Node-RED addon version 15.0.0
Any help appreciated.
Node-RED picks up the time zone from the op system, so HA if you are using NR as an add-on.
The environment variable that holds the current setting is ‘TZ’, thus any inject node (or change node) can be used to read the environment variable ‘TZ’. Worth checking to see what NR is holding, since NR is looking for the full “Europe/London” in my case, and HA only keeps the ‘London’ bit in the settings, so I wonder if there can be a mapping issue from time to time.
Environment variables can be set for NR to read at start up, but the HA add-on has modified settings (which is why you can’t find the setting file you want) and may control time zone more directly. However, there is the ‘process’ library which can now be accessed using function nodes. This can be used to read the env.TZ, and apparently also to set it from within a flow.
I am not going to test this on my live machine (as I don’t want to perturb my running flows) but the following article may help you.
The secret to accessing process.env in the function node is to add the module ‘process’ to the function in the setup section. Just use ‘+add’ at the bottom, select ‘other’ and enter ‘process’. The ‘import as’ is just the name to be used for this module inside NR.
Thank you for all that info, although your answer goes way beyond what I was struggling with :).
I figured some things since my post… I had assumed timestamps coming from (as an example) the inject node were already in local time. This was a bad assumption as they are UTC. Setting up the process.env.TZ = “America/Toronto”; in the settings.js actually worked (I changed it to Los_Angeles , restarted NR and was seeing it in the new placed nodes (i.e. date/time formatter).