How to make something happen every 30 mins (7:00am, 7:30am, 8am, etc)

I have a time announcement on my Elk that runs every 30 minutes between 7am and 10pm. It says “The time is Seven Thirty A.M.”. But, it’s in the Elk’s crappy voice. I’m using Vera Alerts and have vera speaking throughout my house. I want to move the time announcement over to Vera, but it doesn’t look like there is a way through the GUI to tell it to do something on every hour and every half hour on the nose.

I’m assuming the only way to do this is Luup code, but also with some math to figure out if the time is a multiple of 1800 seconds. Or is there an easier way?

There is the option in Scenes to ‘Schedule’ something to occur at a regular ‘interval’ e.g every 30mins?

Will that make it happen on the hour and half hour if I put in 30 mins, or is it 30 mins from when the Luup engine last loaded?

The schedules for scenes are really missing 1 level of specification.
You can specify for a certain time for every day.
You can specify for a repeating interval … but you can’t specify at what time you want the interval to start.

To get around this you can have a scene that triggers every minute.
Inside the LUUP code for the scene you can check to see if the minute is 0 or 15, or 30 or 45.

local Min = os.date("%M")
if ((Min = "00) or (Min == "15") or (Min == "30") or (Min == "45")) then
    Do something here ...
end

Yeah, I tried it without checking the minute, and it does go from the time of the last LUA startup. I added those lines at the top:

[code]local Min = os.date(“%M”)
if not ((Min == “00”) or (Min == “30”)) then
return false
end

local startTime = “08:00”
local endTime = “22:00”

local hour = tonumber( startTime:sub( startTime:find(“%d+”) ) )
local minute = tonumber(startTime:sub(-2))

if hour and minute then
startTime = hour * 100 + minute
else
luup.log(“ERROR: invalid start time”)
return false
end

hour = tonumber( endTime:sub( endTime:find(“%d+”) ) )
minute = tonumber(endTime:sub(-2))

if hour and minute then
endTime = hour * 100 + minute
else
luup.log(“ERROR: invalid end time”)
return false
end

local currentTime = os.date(“*t”)
currentTime = currentTime.hour * 100 + currentTime.min

luup.log("startTime = " … startTime … "; currentTime = " … currentTime … "; endTime = " … endTime)

if startTime <= endTime then
– Both the start time and the end time are in the same day:
– if the current time is in the given interval, run the scene.
if startTime <= currentTime and currentTime <= endTime then
luup.call_action(“urn:richardgreen:serviceId:VeraAlert1”, “SendAlert”,
{Message = “{tone:2}The current time is " … os.date(”%I:%M%p,“), Recipients = “”}, 46)
return true
end
else
– The start time is before midnight, and the end time is after midnight:
– if the current time is not outside the given interval, run the scene.
if not (endTime < currentTime and currentTime < startTime) then
luup.call_action(“urn:richardgreen:serviceId:VeraAlert1”, “SendAlert”,
{Message = “{tone:2}The current time is " … os.date(”%I:%M%p,”), Recipients = “”}, 46)
return true
end
end

return false[/code]

The easy option is:
Download countdown timer.

Set timer to 1800 seconds (= 30 minutes)
create 3 scenes (it can be done in 2 but 3 is easier to create it for now)
scene 1 runs every day you want @ 7 AM (or a other time)
actions: unmute countdowntimer + start countdowntimer

scene 2 runs every day you want @ 10PM
actions: mute countdowntimer

scene 3 runs with trigger
trigger: unmuted countdowntimer is finished.
action: restart timer + the rest you want to do.

If you want the first action be taken at 7AM then you need to start scene 1 @ 6:30 AM

I hope this will get you in the right direction.