Here's how to speak the time every 30 mins between a certain time range

For those of you with this hooked into a whole house speaker system, I though it’d be useful. Stole code and ideas from all of the place. :slight_smile:

Make sure you change the startTime and endTime to what you want, and also scroll down and change the “46” to your Vera Alerts device ID (there are two lines).

Create a scene that executes every minute and put this in the LUUP tab:

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

local startTime = “08:30”
local endTime = “21: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]

Is this a UI 5 only script? It’s not working for me.

I’m on UI5. No idea if there’s anything in it that would cause it to not work on UI4. I don’t have a UI4 box at all.

Try this, it might be the same as above, I just copied/pasted out of my LUUP tab. Remember, you need to set the scene to run every minute for this to work. And if you run it manually, it’s only going to speak the time on 00 and 30 mins, otherwise it will appear to do nothing.

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

local startTime = “08:30”
local endTime = “21: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]

How would one go about this with the latest enhancements to the plugin? I tried to send the example “The current human readable time is {DateTime(CurrentTime,%A %B %d, %Y at %H:%M)}” and Vera Alerts spouts gibberish.

Did you use this in a message from the “Control” tab of Vera Alerts or in a notification message or luup code ?

Ahhhh! I did it from the Control Tab. When it’s in a scene it works! This has to do with needing to change % to something else or some such right? I forgot all about that caveat.

OK I’ve got it working. Now… how to make it only run during specified hours?

Ahhhh! I did it from the Control Tab. When it's in a scene it works! This has to do with needing to change % to something else or some such right? I forgot all about that caveat.
That will be fixed in the next version of Vera Alert. Since there are no controlls on the dashboard device for Vera Alerts ... I will implement my own Control page instead of using Vera's standard logic ... then I can work around the Vera bug.
OK I've got it working. Now.... how to make it only run during specified hours?
That will be in the next release of [b]Program Logic Event Generator[/b] It has timers as well as events. It also has absolute times in the sequence expressions. So if you have a timer named TIMER at what ever interval you want. You can have a condition: SayTime = "08:00:00; TIMER; 20:00:00" Then have a notification where Condition SayTime is satisfied. Then override the notification message with the text you want to have spoken. Code mostly done ... still testing.

All of this is a piece of cake with the recently upgraded Program Logic Event Generator and the shared plugin Program Logic Core

I now have support for absolute times in the sequence expressions.
So you can write condition expressions like:

   Announce = 08:00:00;ScheduleInterval;20:00:00 

In addition to triggers you can now specify and use schedule variables in your condition expressions. A UI similar to that for schedules for a scene is provided. Use it to create the ScheduleInterval schedule for 30 minutes. The plugin has smart startup logic so that if you create an interval timer at a period of 30 minutes … it WILL run on the hour and every 30 minutes, even it Vera reboots!.

Then go to the notification tab and add a notification for A condition is Satisfiedand specifiy the Announce condition.

Go to Vera Alerts and use a text template for this notification that formats the time how you like it!

NO Luup code required!

I installed the PLEG plugin but honestly I’m a little lost here. I created a scene which simply sends the current time to Vera Alerts to be spoken. From what I gather PLEG needs a trigger. Do I need to have a second scene which runs every hour from 8 to 11 (or whenever) which triggers the PLEG which in turn triggers the read time scene?

Need the latest PLEG and PL Core.
It has a Schedule tab … next to the Triggers tab for schedules.
Setup a Schedule (called ScheduleInterval in this example) for every 15 minutes or every 30 minutes etc.

No Scenes needed at all!
Just use the Notification tab for the PLEG … for when Announce is satisfied to send a message to Vera Alerts.

Well, obviously I did something wrong. Upon hitting Save I get a scrolling log repeatedly stating:

Program Logic : Announce = 08:00:00;ScheduleInterval;20:00:00 :[string "module("L_ProgramLogicCCP", package.seeall)..."]:151: Illegal Count

When everything is the same excapt “Erasmus” is notified, the Notification is named “Time Announcement” and under
Setting I changed Condition Expressions to “08:00:00;ScheduleInterval;20:00:00” I get:

08:00:00;ScheduleInterval;20:00:00:[string "module("L_ProgramLogicCCP", package.seeall)..."]:76: Invalid Key token: SCHEDULEINTERVAL

EDIT: Had a typo, an _ after ScheduleInterval the schedule name. Fixed that and now there are no more error messages. There are also no notifications. I have selected “Device Notifications sent via Vera Alerts (In addition to MCV).” I’m not using any of the Vera Alerts Email functionality.

Almost there …
Did you go to Vera Alerts … and to the additional configuration … and save ?

You have to do this if you change/add ANY notification!

I’ve done that. Now I get:

Time Announcement[49] : Startup Lua Failed

I guess I will need to see the Vera logfile.

Can send me the output of:
Your.Vera.IP.Address/cgi-bin/cmh/log.sh?Device=LuaUPnP

Start that before you do a reload.
Send me the result after the log file stabilizes after restart of vera.
You can sent it to PM or my personal email.

Just curious but what whole house system do you guys have hooked into Vera? (trying to figure out what options are available)

I had Elk speakers mounted everywhere from my Elk M1 system. I disconnected them, ran them into a $22 class-T amp from Parts Express, and then got a line level converter for the Elk and ran it into a $20 mixer from the same place. Into another mixer port, I ran an old Android phone.

My house IS wired for a real whole house audio system, but the speakers are not installed. When I go this route, I’m going to buy a case from par-metal.com and fill it with 10 channels worth of amps from 41hz.com. Then I’ll get a cheap rack mount 10+ channel mixer to run everything into. I’ve seen decent ones for under $100 on ebay that have serial port control. I don’t see any reason to spend a ton of money on Russound or anything else when all of the control can be done through my phone using automation tools.

[quote=“signal15, post:17, topic:173310”]I had Elk speakers mounted everywhere from my Elk M1 system. I disconnected them, ran them into a $22 class-T amp from Parts Express, and then got a line level converter for the Elk and ran it into a $20 mixer from the same place. Into another mixer port, I ran an old Android phone.

My house IS wired for a real whole house audio system, but the speakers are not installed. When I go this route, I’m going to buy a case from par-metal.com and fill it with 10 channels worth of amps from 41hz.com. Then I’ll get a cheap rack mount 10+ channel mixer to run everything into. I’ve seen decent ones for under $100 on ebay that have serial port control. I don’t see any reason to spend a ton of money on Russound or anything else when all of the control can be done through my phone using automation tools.[/quote]

Would you be so kind as to start a thread in the AV forum describing this in greater detail and logging any changes with comments? From browsing the forums for other HA systems I have noticed that TTS and the like is very important to many people and it is about to become important to Vera users so your experiences would be highly appreciated.

I myself am simply placing computer speakers in different rooms for Vera Alert messages. I plan on powering them with Evolve and GE Z-Wave outlets so control of which room hears which announcements will be controlled by which outlets have power. I know it’s not too elegant but I have many obstacles to overcome and currently this seems to be the best choice.

@ RTS, I’m working on that log file now and will send it off to you momentarily.

I’ll toss something in there later tonight or tomorrow. I should point out that many of my speakers are just using unused pairs in my existing phone wiring. I don’t have a home phone, so I just took my phone jacks out and replaced them with the Elk speakers, which fit perfectly in the boxes. If you still have a phone, chances are that you’re not using all the pairs and you could put a remodel box next to your phone jack and run two wires over.

Yes, the little teeny 24 gauge phone wire works just fine for them.

@ signal15,

How is your audio distributed to the different speakers without having to fiddle with impedance matching and the like? I’m wiring up some speakers today and am worried about this.