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.

1 Like

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

is there any news?
Groovy has access to the user location object with timezone and sunrise/sunset times. It would be great to have the same features in Lua.

4 Likes

I’m writing an edge driver that calculates solar position and times. This requires to know the location (latitude and longitude) as well as the local time (or alternatively, the timezone). It would be very useful for edge drivers to have access to a location object like there was in groovy DTH.

3 Likes

Hi,

I’m looking for a way to provide a user with timestamp of some operation.
For example,

  • energy meter reset
  • power outage counter reset
  • non-presence detection reset for Aqara FP1 (since manual reset might be required in some cases)
  • sensor’s last action (last motion detection timestamp or door open, etc)
  • virtual counter (to allow user to count how many times the door was opened since the last reset) reset timestamp

Also, to synchronize time between the hub and some zigbee devices that support time based activations without hub’s intervention. For example, some devices can be configured to change the state at specific time even if the hub is down or the connection to was lost

@TAustin and @Mariano_Colmenarejo have date/time stamp on energy meters resets

Thank you @milandjurovic71 ,

Does it show a local time?
If so, does it require setting an offset or a time zone in device preferences or capabilities?

This drivers show date only, but some other @Mariano_Colmenarejo drivers show local time. They all need UTC offset to be set

The Dishwasher capability shows time, and it seems like it’s local

basically you want to create better history tab :slight_smile:

it might be easier just to create a web app or just better mobile app %)

1 Like

@milandjurovic71

I find it highly unreasonable to request from the user to set timezone for each and every device.
I think timezone should be a property of location and should be set only once.
Drivers should be either able to retrieve the local time from the hub/location or they should be able to at least retrieve the time zone settings.

4 Likes

I would guess the dishwasher has WiFi connection and is able to retrieve local time by itself, without Zigbee hub intervention.
Then it just can feed the capability with whatever value.
I really doubt your dishwasher has Zigbee connection only.