Lua time question

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
peterbos
Posts: 93
Joined: Saturday 07 November 2020 21:41
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Lua time question

Post by peterbos »

Hi all,

If I want to override a temperature setting in an Evohome system through the API, I use the updateSetPoint command. This command takes three parameters: temperature, setting ('TemporaryOverride' or the less readable 'domoticz.EVOHOME_MODE_TEMPORARY_OVERRIDE') and the datetime until the setting is valid. If I omit the datetime, the setting will go back to the normal setting at the moment the normal program changes. The datetime is in ISO 8601 format e.g.: "2023-06-01T13:41:00Z".

I made a presence detection with a virtual switch that changes only at the moment the house gets empty or someone enters again. If the house is left, I override the normal Evohome setting. I want to keep that setting until 4:00 in the night. If someone enters before that time the Evohome immediately goes back to the normal schedule, otherwise it does at 4:00. My problem is the time setting for the Evohome. I use the Lua time and date function:

Code: Select all

-- Don't worry, in my actual code I don't use this much lines and parameters :-)
secsCurrentUTC = os.time() % (24 * 60 * 60)             -- seconds since midnight in UTC
secsCurrentTime = secsCurrentUTC + 60 * 60              -- seconds since midnight in my timezone (Central European Time, CET = UTC+1)
secsUntilMidnight = 24 * 60 * 60 - secsCurrentTime      -- seconds until midnight
secsUntilEndtime = secsUntilMidnight + 4 * 60 * 60      -- seconds until next morning 4:00
datetimeEndtime = os.time() + secUntilEndtime           -- the datetime for next morning 4:00
utcEndtime = os.date("!%Y-%m-%dT%TZ", datetimeEndtime)  -- the UTC to pass to the updateSetpoint function
evohomeZonename.updateSetPoint(theTemperature, 'TemporaryOverride', utcEndtime)
This works at the moment in CET but will this also work in daylight saving time (CEST), when I'm on UTC+2? Does Domoticz change to and from DST on the last Sundays of March and October? I know it won't work correctly in those two night but that's a problem I accept.

Peter
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest