edterbak / NodeRed_Heishamon_control

a Node Red flow to interact with Heishamon (a panasonic heatpump through an ESP board)
35 stars 6 forks source link

[BUG]: DateTime Timezone #158

Closed geduxas closed 5 months ago

geduxas commented 5 months ago

Describe the bug

Tried to use time scheduler, and noticed that it didn't worked in time it expected to be, tried to find out what's wrong, noticed that my LOG's are offset by -1h from my current time. (My time zone is "Europe/Vilnius")

Using HomeAsisstant with node-red AddOn, All time zones ar set to my local TZ. Node-Red addon container is running with TZ="Europe/Vilnius" flag, image

Node-red date commands shows my local date time and timezone correctly. image

Tried to add TZ to node-red settings.json as stated here: https://community.home-assistant.io/t/solved-wrong-timezone-in-node-red-correct-time-in-hass-in-docker-container/74113/25 log file still shows -1h from my local time.

image

edterbak commented 5 months ago

I am looking into it.

Can you tell me what timezone you have selected in Heishamon? your timezone should be telling (value wise) UTC+02:00 right?

In Node Red, if you insert an injection node with timestamp, what is the timestamp telling you? Put a debug node after it, and in the debug window, click on the number to roll throught the various formats. Is it the same/correct date?

edterbak commented 5 months ago

In my case, I am in the Netherlands. Timezone is with winter/summer time correction. (CET/CEST, corresponding to UTC+1h/UTC+2h)

Current official timezone is UTC+1h In Node Red; when I inject a timestamp into a debug node, I see "17-1-2024 22:57:50 [UTC+1]" This is the correct time, in my case.

What do you see if you do this? Timezone in Vilnius shows (from website https://www.timeanddate.com/time/zone/lithuania/vilnius) Also winter/summer correction UTC+2h/UTC+3h. SO the debug SHOULD shown the UTC+2 as well on your end.

edterbak commented 5 months ago

Found it. I see I hardcoded the timezone to Europe/Amsterdam.... 😄 😄 I will make it a config item in the system tab in next release

Can you test if this works for you as well? Tab [WP Dash] Search for node : "a2d45addc303107f" and "46c5b8fae5c96441". Change the Output Timezone to "Europe/Vilnius", like this:

image

In my case, there is a +1 hour change after changing it, which should be exactly what you are missing :)

geduxas commented 5 months ago

Hi, yes I looked in those time date/time formatters, and also noticed that all of them are expecting UTC time zone and convert's them to Amsterdam time zone, you are really fast :D so time stamp identifies time correctly I think [2024-01-17T22:22:14.902Z] Is there a reason to convert time format's?

geduxas commented 5 months ago

And yes, after changing in logs node time shows correctly.

edterbak commented 5 months ago

If I do not use this node, Date/Time formatter, the time changes for summer/winter time will not be set automatically. This node makes it easy to convert from timestamp to readable date format.

I will improve the timezone stuff, so that a user can change TZ from GUI. :) should be easy enough.

edterbak commented 5 months ago

It is fixed in next release, which should be v24.04

In NodeRed GUI, you can now set the timezone.

image

18/01 01:06:14 - SYSTEM: TimeZone set to: Europe/Amsterdam 18/01 02:06:07 - SYSTEM: TimeZone set to: Europe/Vilnius 18/01 08:05:49 - SYSTEM: TimeZone set to: Hongkong 17/01 19:05:22 - SYSTEM: TimeZone set to: Jamaica 18/01 04:05:08 - SYSTEM: TimeZone set to: Europe/Astrakhan

~600 timezones are present to chose from.

geduxas commented 5 months ago

Oh my... It will definitely increase json size :D

Thanks @edterbak