Hi! It seems that I’m always getting UTC as local time from the hub. What’s the best way to either get local time, or the timezone the hub is in so I can do the math?
Hi, @mwilkie!
Please, take a look at this thread:
There is still some incomplete information about that but I think the updates related will be added there so you can follow up there.
So far, getting the local time within a driver is not possible.
And 2 years later it seems still to be not possible. Am I right?
Hi, @alex.49.98
Sorry for the delay, I was tracking the information about this.
So, I got curious about your use case since drivers can work based on timers but in this case, do you need to get the local time?
If you’re trying to automate a behavior, you can create Routines or Rules through the API instead.
Is there something you can’t accomplish using those tools?
That’s a great remark that Rules can work with local time, and I wonder how come that they can do it, but drivers cannot? If I’m not mistaken, I read somewhere that Rules are executed directly on the Hub and if that’s true the Hub has a notion of local time, then I guess there shouldn’t be an issue to expose this concept to a driver.
The use case is this, I create a driver that orchestrates behavior of a number of different devices: light sensors, motion sensors, door sensors, lights, power outlets, etc and we are talking about dozens of those. Potentially, I guess, most of the logic implemented in the driver can be expressed as rules but that will require writing very complex rules and with any change in the device list the rules will need to be updated plus I’m not sure that all complex behavior can be expressed as rules. The driver allows to automate and provide simple way for customization. A part of the driver logic relies on the time of the day when the behavior should change let’s say after 6PM local time until midnight local time or between 12PM and 2PM.
I know, I can add another driver setting like a time zone, but it seems that the Hub knows local time somewhere internally, so, why don’t expose it to the drivers?
Hi @nayelyz
This feature was already requested in November 2021 and these were the responses, maybe it’s time to give it a new boost, thanks
The time in Rules is set as an offset from midnight, noon, sunrise or sunset in the ST Location. If those are provided in UTC there is no need for local time.
Routines add a timezone on top of the base Rules because the editor UI is localised to where the phone is at the time.
I think you need to build a case for not doing so as in broader terms having the user specifying the timezone seems like it could be ‘a good thing’. It assumes nothing.