ottopaulsen / node-red-contrib-power-saver

A Node-RED node to saver money by turning off when the power is most expensive
Other
71 stars 17 forks source link

ps-general-add-tariff - Valid from date and UTC time #77

Open otsafe opened 2 years ago

otsafe commented 2 years ago

If I send {"value":0,"start":"2022-06-30T22:00:00.000Z"} (which is basically July 1st. in Norway when time zone is +2) to this node, and have specified "Valid from date: 2022-07-01" and set a value to add to the input value. it returns 0, instead of 0+the value.

So if I send an array for the whole July, it returns 0 on the 2 first hours, then shows the correct values after then. As far as I can see, the time field is time zone aware, but the date field is not.

A workaround is to format the date field with moment, so it is not sending date as UTC time, but as local time.

moment(date_var).format("YYYY-MM-DDTHH:mm:ss.SSSZ")

image

Using v3.6.1

ottopaulsen commented 1 year ago

As you can see, there is no timezone in the config, so the config is applied to the data as is, whatever timezone they have. That makes sense, since when we say 06:00 we mean 06:00 no matter if it is DST or not, for example. Tibber, for example, sends data with the local time zone, so if you use that API, it should work always. If you have a source with other data, you could convert. I prefer luxon over moment, but that is of course entirely up to you :-)