Having been a vera user for over 4 years dating back to Vera I, I should know this, but I want a scene to simply turn a device on for an hour and off for an hour, round the clock.
My simple mind set up a scene with a Timer set to a 2 hour interval. The associated Command was to turn the Device on for 1 hour and then turn off. This does not seem to be achieving 50% on and 50% off. My guess is that the timer is waiting until the command has ended of being on for an hour and then waiting 2 hours to activate 1 hour on then off. Is this the case?
My thinking was that when the scene timer would activate at noon and 2:00 etc allowing the command to execute for only one hour. That does not seem to be occurring.
Also, if an interval based timer is ‘run’, and the timer on the interval is ‘counting time’, then if I rerun the command 30 minutes later does it run simultaneous to the first scene timer or does it replace (overwrite) the existing scene command?
I apologize for the simple nature of this question, but I’ve never run across this before. ???
Best Regards,
[quote=“nwrunner, post:1, topic:179179”]Having been a vera user for over 4 years dating back to Vera I, I should know this, but I want a scene to simply turn a device on for an hour and off for an hour, round the clock.
My simple mind set up a scene with a Timer set to a 2 hour interval. The associated Command was to turn the Device on for 1 hour and then turn off. This does not seem to be achieving 50% on and 50% off. My guess is that the timer is waiting until the command has ended of being on for an hour and then waiting 2 hours to activate 1 hour on then off. Is this the case?
My thinking was that when the scene timer would activate at noon and 2:00 etc allowing the command to execute for only one hour. That does not seem to be occurring.
Also, if an interval based timer is ‘run’, and the timer on the interval is ‘counting time’, then if I rerun the command 30 minutes later does it run simultaneous to the first scene timer or does it replace (overwrite) the existing scene command?
I apologize for the simple nature of this question, but I’ve never run across this before. ???
Best Regards,[/quote]
The most reliable way to do this is to run the scene with an interval schedule of one hour and toggle the light each time. Attempts to synchronize multiple scenes will fail when Vera restarts. The following Luup code, placed in the scene’s main Luup tab will toggle the light. Change dID to the device number of your light.
local dID = 66
local status = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", dID)
local target = (tonumber(status) + 1) % 2
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue=target },dID)
Thanks so much Rex, I’ll do that. I was wondering if Luup code was the way to go. However, to be clear the command was in the same scene as the timer (but maybe that’s what you mean by multiple scenes, a combination timer/command in the same scene).
My command is light on for 1 hour then off, timer interval event every 2 hours. But, I’ll be using the Luup code.
Do you happen to know if there are any basic Luup programming classes slanted toward Vera? I’ve googled Luup classes and it seems to always resolve to C++ or array theory. Perhaps Lua.org is my best source.
Regards,
You can also do this quite easily with PLEG.
One Input Schedule
DualState Interval Timer … Starts every two hours, Off time in 1 hour.
One Condition:
LightState DualState ? “1” : “0”
One Action:
LightState Turn on Light
Then go into the ADVANCED tab for the Action and change the 1 for the SetTarget command to: {(LightState)}
This will actually set the light to the value of 1 or 0 depending on the state of the timer.
And if Vera reboots … during the cycle … it will pick right back up without starting a new 2 hour interval cycle.
With scene’s if you are 1 minute from running … and Vera restarts … then it will start the 2 hour timer again.
Do you happen to know if there are any basic Luup programming classes slanted toward Vera? I've googled Luup classes and it seems to always resolve to C++ or array theory. Perhaps Lua.org is my best source.
The book Programming in Lua by Roberto Ierusalimschy is probably the best place to start learning Lua.
You would almost certainly get your automation working better/quicker using PLEG so, unless it is important to you to learn programming, spend the time learning PLEG. PLEG Basics is free. 