Receiving only UTC time from Home Assistant controller
-
I'm not sure if this is a MySensors or Home Assistant issue, but using the example at https://www.mysensors.org/build/display to read the time from my HA controller, it always pulls the UTC time where in the MySensors library documentation here it states that
void receiveTime(unsigned long ts);
returns ts "Adjusted for timezone by controller."I have the time_zone parameter correctly configured in my Home Assistant's configuration.yaml file.
As a workaround I have the sensor node convert the time using this piece of code:
#include <Timezone.h> #include <TimeLib.h> TimeChangeRule CEST = { "CEST", Last, Sun, Mar, 12, 120 }; // Central European Summer Time, 2 hrs offset TimeChangeRule CET = { "CET ", Last, Sun, Nov, 5, 60 }; // Central European Standard Time, 1 hr offset Timezone CE(CEST, CET); : : TimeChangeRule * tcr; time_t t = CE.toLocal(controllerTime, &tcr); RTC.set(t);
But it would good to know if its a bug or I'm just doing something incorrect?
-
@Paul-Derbyshire
Hi!
This is a bug or at least a deviation from the mysensors API. We should fix it. Should be just a matter of using the correct time function, I think.
-
@martinhjelmare is this something I can help contribute too?
-
@Paul-Derbyshire
Yes! Make a PR to pymysensors repository at github. I think
calendar.timegm(time.localtime())
should return the correct time.
-