Scene with multiple delayed actions

I just recently installed a CT 100 z wave thermostat and setup a scene that runs Monday - Friday at 12:00 am with multiple delayed actions to adjust the temperature throughout the morning, day and evening. After reading through the Vera knowledge base, wiki and searching this forum - it sounds like a scene can have “stacked” delayed actions. However, for the last two days, it seems like only the trigger and first delayed action is ever ran and the thermostat just holds that temperature (76 degrees) till the following day at 12:00am, where the scene then is ran again.

What I would like to happen is:
[td]12:00am[/td][td]7:59am[/td][td]71 degrees[/td]
[td]8:00am[/td][td]11:59am[/td][td]76 degrees[/td]
[td]12:00pm[/td][td]1:59pm[/td][td]74 degrees[/td]
[td]2:00pm[/td][td]6:59pm[/td][td]76 degrees[/td]
[td]7:00pm[/td][td]9:29pm[/td][td]74 degrees[/td]
[td]9:30pm[/td][td]11:59pm[/td][td]71 degrees[/td]

I have attached a screen shot of my scene setup, from what I can tell via the documentation all delayed actions should be from the scene start time. I am not seeing any alerts to an issue so as far as I can tell, Vera thinks everything is working - but it isn’t really.

I have a Vera 3 running UI7 version 1.7.690


Don’t have UI7 (yet), but things look fine to me.

I don’t use scenes much as I use PLEG, but could it be that vera reboots? I think I remember that if vera reboots it looses that delay info.

Also I know PLEG has problems crossing the midnight mark as it uses time but not days.

I quick fix would just be to setup different scenes vs. one with a bunch of delays.

Thanks for the info!

I did see stuff about “delayed actions” not firing after a Vera reboot and that makes sense - I haven’t manually rebooted it though since I setup this scene, can it automatically reboot itself during the day if it needs to?

Yep - I could use multiple scenes, but was trying to keep things nice/neat and prevent having 20+ scenes for summer/winter weekday/weekend thermostat changes - although I may not have a choice.

I am not familiar with PLEG or scripting a scene through code - but doing it this way doesn’t bother me (I have a technical/coding background) if I could achieve what I want.

Maybe it’s just a bug in UI7?

Again thanks!

You really don’t want scenes hanging around all day (if only for the failure after restart problem.)

Simply schedule a scene to run, say, every 5 minutes and insert this Lua code:

-- schedule this scene to run every 5 minutes, or so.

local schedule = {
  {0, 71},          -- 12:00am	7:59am	71 degrees
  {8, 76},          -- 8:00am	 11:59am	76 degrees
  {12, 74},         -- 12:00pm	1:59pm	74 degrees
  {14, 76},         -- 2:00pm	  6:59pm	76 degrees
  {19, 74},         -- 7:00pm	  9:29pm	74 degrees
  {21.5, 71},       -- 9:30pm	 11:59pm	71 degrees

local t = "*t"
local now = t.hour + t.min / 60

local temp
for _,s in ipairs(schedule) do
  if now > s[1] then temp = s[2] end

local sid = "urn:upnp-org:serviceId:TemperatureSetpoint1"
local act = "SetCurrentSetpoint"
local arg = {NewCurrentSetpoint = temp}
local dev = ???

luup.call_action (sid, act, arg, dev)  -- set the thermostat to temp
-- done!

It just wakes up every 5 minutes, checks what the current temperature should be, and sets it.

You may need to modify the action and argument (and you will have to decide the device number) depending on your HVAC device.

Also I know PLEG has problems crossing the midnight mark as it uses time but not days.
I do not know of any problem!

The Original Post would work with the intent of minimizing clutter in PLEG.

  1. Define Start Schedule.
  2. Define condition triggered by Schedule (NOTE a Condition is equal to a Vera Scene)
  3. Add actions to the Condition … PLEG does NOT have the same problems as Vera when Vera reboots.

I’m with AKB on this one plus the work is already done…

I’m running a Vera3 with UI7 (619) and I have a scene (just one where I built it using Advanced Scene Editor) whereby there’s maybe 2 hours in between (turns main lights off then 1 hour later turns all other lights off) and it’s a hit and miss kind of thing. I woke up last night 'cause my dog was like, hey - WTF, think you can turn off these lights so I can crash (seriously). It was like 1:30am and I had to find my iPad and shut them off manually. This happens at least once every week… Another nail in MCV’s coffin so to speak. Sure would like automated to mean automated…

Thanks for the help!

akbooer - definitely appreciate the code, didn’t have an previous experience programming with lua in vera. After looking it over and digging through the forums some more I started thinking whata else I could achieve.

What I basically did was take my previous four scenes created through the UI and combine them into a single script that is run via a scene that fires every 5-10 minutes as akbooer suggested. This script checks to see if Heat or Cool is on and then based on the day of the week, runs a particular schedule. It also only adjusts the current setpoint temperature if there is change from what it is currently set at and if the system is idle.

-- Scene scheduled to run every 5 minutes, or the minimum to hit a temp change.

-- Determine if mode should run
local function runSchedule(timeNow, currentModeStatus, mode, days)
  return days[timeNow.wday] and currentModeStatus == mode

-- Fuction to help us search an array
local function Set (list)
  local set = {}
  for _, l in ipairs(list) do set[l] = true end
  return set

-- Device Id
local deviceId = 1

-- Get current thermostat mode, possible values "Off", "HeatOn", "CoolOn", "AutoChangeOver"
local currentModeStatus = luup.variable_get("urn:upnp-org:serviceId:HVAC_UserOperatingMode1", "ModeStatus", deviceId)

-- Get current thermostat state, possible values "Idle"
local currentModeState = luup.variable_get("urn:micasaverde-com:serviceId:HVAC_OperatingState1", "ModeState", deviceId)

-- Current set point temperatures
local currentSetPointCool = tonumber((luup.variable_get("urn:upnp-org:serviceId:TemperatureSetpoint1_Cool", "CurrentSetpoint", deviceId)))
local currentSetPointHeat = tonumber((luup.variable_get("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat", "CurrentSetpoint", deviceId)))

-- Get the current date/time
local timeNow = "*t"
local temperatureSchedule

if runSchedule(timeNow, currentModeStatus, "CoolOn",  Set {2, 3, 4, 5, 6}) then

  temperatureSchedule = {
    {0, 71},          -- 12:00am  7:59am  71 degrees
    {8, 76},          -- 8:00am  11:59am  76 degrees
    {12, 74},         -- 12:00pm  1:59pm  74 degrees
    {14, 76},         -- 2:00pm   6:59pm  76 degrees
    {19, 74},         -- 7:00pm   9:29pm  74 degrees
    {21.5, 71}        -- 9:30pm  11:59pm  71 degrees

elseif runSchedule(timeNow, currentModeStatus, "CoolOn", Set {1, 7}) then

  temperatureSchedule = {
      {0, 71},         -- 12:00am  7:59am  71 degrees
      {8, 74},         -- 8:00am  11:59am  74 degrees
      {21.5, 71}       -- 9:30pm  11:59pm  71 degrees

elseif runSchedule(timeNow, currentModeStatus, "HeatOn", Set {2, 3, 4, 5, 6}) then

  temperatureSchedule = {
      {0, 64},          -- 12:00am  7:59am  71 degrees
      {19, 66}          -- 7:00pm  11:59am  74 degrees

elseif runSchedule(timeNow, currentModeStatus, "HeatOn", Set {1, 7}) then

  temperatureSchedule = {
    {0, 64},            -- 12:00am  7:59am  71 degrees
    {9, 66}             -- 9:00am  11:59am  74 degrees


local nowHour = timeNow.hour + timeNow.min / 60
local newSetPoint
for _,s in ipairs(temperatureSchedule) do
  if nowHour > s[1] then newSetPoint = s[2] end

-- Set the setpoint only if it has changed and the system is idle
if currentModeState == "Idle" then
  if currentModeStatus == "CoolOn" and currentSetPointCool ~= newSetPoint then
    luup.call_action("urn:upnp-org:serviceId:TemperatureSetpoint1_Cool", "SetCurrentSetpoint", { NewCurrentSetpoint = newSetPoint }, deviceId)
  elseif currentModeStatus == "HeatOn" and currentSetPointHeat ~= newSetPoint then
    luup.call_action("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat", "SetCurrentSetpoint", { NewCurrentSetpoint = newSetPoint }, deviceId)

Haven’t tested it yet - but looks like it should do the trick. Since this is my first script, any feedback/tips/tricks are appreciated.

Bumping this topic, as I’ve found a problem I can’t seem to solve with a delayed scene action…

I have a very simple scene that lights a pathway to goto bed. Basically it just turns on a couple of hallway lights, then waits for 2 minutes, and then turns off all of the other house lights as well as the hallway lights. The second step is not firing. As I said, the delay is only 2 minutes, so it’s not like I’m in a holding pattern for multiple hours or crossing over the midnight line or anything like that. Step 2 simply isn’t happening.

This is of greater concern because I have a scene that runs when I’m away to make the house look occupied. Again, very simple, turns some lights on in the bedrooms, off in the main rooms, and then 10 minutes later shuts off the bedroom lights. If that second step isn’t firing, that means my bedroom lights are burning until my catch-all “ALL LIGHTS OFF” scene fires at 3:00am.

Any ideas on why delays aren’t working? Is this a known issue?

We are going to need a lot more information before we can answer.

Are you doing the delays via LUA script, through the normal Vera scene interface, or through PLEG? If LUA code, can you show it?

My delayed actions are setup through the standard Vera scene building interface. No LUA code, not using PLEG. Just a simple…execute n things “immediately” and execute y things “after a 3 minute delay”. I have attached a snapshot of the editor view of my scene FYI.

Also, while I realize it’s not a highly meaningful test because the scene is definitely firing (the first part, at least), I have executed the scene from my scene controller button, the Vera interface, and the mobile interface, all with the same result - step 1 executes, step 2 never executes.

You could try creating the same scene again but without the immediate actions. Perhaps something in the devices in the immediate actions is causing an immediate reload which is killing the delayed actions. Also try reducing the delay (for testing) and then gradually increase again.

Thank you. Magically, the delayed action scenes are now working. I’m no hallucinating - they definitely were not yesterday. But in my experience, this wouldn’t be the first time Vera has displayed mysterious and inconsistent behavior.

To be certain, I have gone in and changed the delays a few times, and the scenes seem to be fine now. On to the next challenge…