Retrieve the date and time in a scene

Feature description

Following this thread: Récuperer date/heure dans mqtt - #3 par prohand

I think it would be nice to be able to retrieve the time locally in a scene and not via an external web service :slight_smile:

@pierre-gilles I’m bringing this request back up, which could be included in next week’s updates.

I describe a use case:

To monitor the startup of my heat pump (it’s new, I want to keep an eye on its operation regularly), I want to be notified every hour of the last startup. A message like « The last startup of the heat pump was 26 minutes ago Â»

I would therefore like to do the following:

  • Create a virtual MQTT device â€č last heat pump startup â€ș
  • In scene A, with the trigger being the heat pump starting, store the current date/time in this MQTT device
  • In scene B, which triggers every hour, retrieve the current date/time and the â€č last heat pump startup â€ș date, calculate the difference and send me a message

For this, Gladys would need to:

  • Be able to create a virtual device of type â€č date and time â€ș
  • Have a scene action to retrieve the current date and time as a variable, usable in the rest of the scene (perhaps by indicating the expected â€č precision â€ș: second, minute, hour, day,
 Because for example in my case the minute would suffice, and if Gladys gives me info to the millisecond, my message will be unnecessarily precise)
  • Define how a â€č date and time â€ș device is taken into account in a scene calculation. I think it’s the â€č timestamp â€ș in seconds that could be used

  • Have a clean display if I display a â€č date and time â€ș device on the dashboard, with the possibility to choose the display format

Hi everyone!

This topic is now under development.

A PR has been opened to add a scene action « Get date and time » (date, time, datetime and timestamp, with adjustable precision):

Feel free to follow the PR, test (optional, especially for small requests) and give your feedback here if needed.

I tested on my side, everything is ok :wink:

Cool if we no longer have to make an HTTP GET request to retrieve the date and time :wink:

But does this take into account the host Gladys’s time?
Because I think I have a difference when I look at the logs and the corresponding times, 1 or 2 hours :frowning:

It seems to take the host Gladys’s time
image

The times in the logs of external integrations are in UTC
I checked that the Gladys Docker logs are indeed in the correct timezone

I will create a feature request for the timezone of external integrations