I have four scenes that I use to adjust the alarm time of a VClock in response to triggers from remote UIs. The scenes either increase or decrease the alarm time by 15 minutes or one hour. I’ve included the Lua for the four scenes below:
-- Add 15 minutes to Alarm Time
local sEarly = luup.variable_get("urn:upnp-org:serviceId:VClock1", "AlarmTime", 92)
local hour = tonumber(string.sub(sEarly,1,2))
local minute = tonumber(string.sub(sEarly,4,5))
local second = 0
minute = (math.floor((minute + 7)/15) + 1) * 15
if minute >= 60 then minute = 0 hour = hour + 1 end
if hour > 23 then hour = 0 end
sEarly = string.format("%02d:%02d:%02d",hour,minute,second)
local lul_arguments = {}
lul_arguments["newAlarmTimeValue"] = sEarly
luup.call_action("urn:upnp-org:serviceId:VClock1","SetAlarmTime",lul_arguments,92)
-- Add 1 hour to Alarm Time
local sEarly = luup.variable_get("urn:upnp-org:serviceId:VClock1", "AlarmTime", 92)
local hour = tonumber(string.sub(sEarly,1,2))
local minute = tonumber(string.sub(sEarly,4,5))
local second = 0
hour = hour + 1
if hour > 23 then hour = 0 end
sEarly = string.format("%02d:%02d:%02d",hour,minute,second)
local lul_arguments = {}
lul_arguments["newAlarmTimeValue"] = sEarly
luup.call_action("urn:upnp-org:serviceId:VClock1","SetAlarmTime",lul_arguments,92)
-- Subtract 15 minutes from Alarm Time
local sEarly = luup.variable_get("urn:upnp-org:serviceId:VClock1", "AlarmTime", 92)
local hour = tonumber(string.sub(sEarly,1,2))
local minute = tonumber(string.sub(sEarly,4,5))
local second = 0
minute = (math.floor((minute + 7)/15) - 1) * 15
if minute < 0 then minute = 45 hour = hour - 1 end
if hour < 0 then hour = 23 end
sEarly = string.format("%02d:%02d:%02d",hour,minute,second)
local lul_arguments = {}
lul_arguments["newAlarmTimeValue"] = sEarly
luup.call_action("urn:upnp-org:serviceId:VClock1","SetAlarmTime",lul_arguments,92)
-- Subtract 1 hour from Alarm Time
local sEarly = luup.variable_get("urn:upnp-org:serviceId:VClock1", "AlarmTime", 92)
local hour = tonumber(string.sub(sEarly,1,2))
local minute = tonumber(string.sub(sEarly,4,5))
local second = 0
hour = hour - 1
if hour < 0 then hour = 23 end
sEarly = string.format("%02d:%02d:%02d",hour,minute,second)
local lul_arguments = {}
lul_arguments["newAlarmTimeValue"] = sEarly
luup.call_action("urn:upnp-org:serviceId:VClock1","SetAlarmTime",lul_arguments,92)