Local time

Is there a way to pull local time (or the local time zone)? I’ve only been able to get UTC out of os.date().

2 Likes

I couldn’t get it either.

What I did is put a preference so that the user can enter the difference between their local time and UTC

1 Like

Going down that path means I’m either updating offsets twice a year for each device or figuring out a function to handle DST. Seems like it should be possible since timezone is set on the location.

It should be possible.
https://developer-preview.smartthings.com/edge-device-drivers/global_environment.html#os.date
I looked in the documentation and also tried os.date () and with:

os.setlocale (locale [, category])

Sets the current locale of the program. locale is a system-dependent string specifying a locale; category is an optional string describing which category to change: “all”, “collate”, “ctype”, “monetary”, “numeric”, or “time”; the default category is “all”. The function returns the name of the new locale, or nil if the request cannot be honored.

waiting for a solution!

Hi @philh30 @Mariano_Colmenarejo, right now this is expected. On several platforms including V2/V3 we do not have any timezeone/locale information directly available on target or cannot really be trusted. Our best bet for a consistent local time provider would be to use information from the location in which the hub belongs which adds a bit of complexity.

For prioritizing any feature, do you have some specific examples of cases where local time is required for the correct operation of a driver? Many concerns that would normally require local time (e.g. turn on the lights at 7AM) are properly handled via automations rather than directly in drivers.

1 Like

wait but how does the local automations work then?

For prioritizing any feature, do you have some specific examples of cases where local time is required for the correct operation of a driver? Many concerns that would normally require local time (e.g. turn on the lights at 7AM) are properly handled via automations rather than directly in drivers.

Automations are either manual or on the JSON-based language ST team invented.

For example:
I want all of my lamps to turn on dimmed 5% from 22:00. disregarding the source: from Google Assistant, motion sensor, button or automation.

Option 1: create dozens of rules manually
Option 2: be a genius who learned st-json something
Option 3: run in the slow Cloud

! Option 4: fork the driver and override turn on command

2 Likes

I am using local time for the circadian lighting function in the zigbee Light multifunction driver.
According to the local time, the light turns on with a certain intensity and color temperature and it changes continuously while light is turned on.

Also to give information to user of when the next change of state will occur in the random on-off function and in the fan programming in the thermostat driver.

2 Likes

How would driver handle the time class for devices (eg thermostats and locks)?

I believe for these, the gateway (hub) is acting as a server so drivers are not involved in that particular flow but admit that I am not the expert on all of these details. I do think we will want to provide consistent local time to drivers, just sorting out use cases to aid in determining priority of various work items.

Support in one portion of the hub software does not automatically imply that the support is available in the highly sandboxed lua driver environment which is the difference here. Exposing all of a user’s data to drivers would be a Bad Idea™ and violate security principles we seek to follow such as the principle of least privilege.

Anyway, thanks @rboy, @veonua, @Mariano_Colmenarejo for the feedback. I think the ask is reasonable, just gathering a few use cases.

1 Like

My primary use case is a z-wave pool control (Intermatic pe-653). The device has internal schedules, which are programmed via config parameters. I prefer the internal schedules over hub automations since there are fewer points of failure. However, the device’s clock has to be set by the hub.

Similar situation with my z-wave thermostat. I use the internal schedules, and it has an internal clock that can be set by the hub. Yes, I can hit the buttons on it to change the time, but this is one of those little hassles in life that SmartThings should be able to handle for me.

Neither device adjusts itself for DST. Both eventually drift away from the correct time and need to be adjusted.

2 Likes