Hi guys/gals, I have a veralite and EVL3 ip communicator talking to my Vista20P panel. All my automation works perfect but I’d like to create a couple of scenes to do some simple tasks. Fist of all, I have my outdoor lights controlled by a z-wave on/off switch. Again, the veralite communicates to the EVL3 and the zwave light switch. I’d like to setup a scene that would flash my outside lights (3 sec on 3 sec off per say) if my security alarm goes off and the lights go off if the alarm is silenced. In summary Trigger = alarm on, alarm off (not armed and disarmed but actually breached alarm status)Lights flash on/off or completely off once the alarm is silenced… Any suggestions?
You will need to do this in LUA code.
- One trigger to start the flash loop.
- A second trigger to stop the flash loop.
The flash rate will be limited by Z-Wave performance.
There are multiple examples of this in the forums.
Hi Guys,
Ok, So I created two scenes…
Scene 1 called ALARMActiveFlashON and used the following LUA CODE (13 is my outside pot lights switch, 3sec on/off timer).
function DipOnPorchLight(stuff)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },13)
if (sBlink == “1”) then
luup.call_timer(“DipOffPorchLight”, 1, “3”, “”, “”)
end
end
function DipOffPorchLight(stuff)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },13)
if (sBlink == “1”) then
luup.call_timer(“DipOnPorchLight”, 1, “3”, “”, “”)
end
end
if (sBlink == “1”) then
sBlink = “0”
else
sBlink = “1”
luup.call_timer(“DipOffPorchLight”, 1, “3”, “”, “”)
end
I used the Vista Alarm Partion 1 ACTIVEALARM action bit to trigger the scene under the scene TRIGGER tab. Without actually setting the alarm off, I simply RAN the scene and it flashes my lights! Great.
Then I created the second scene
Scene 2 called ALARMNonactiveFlashOFF and simply used the device OFF button triggered but the NONACTIVEALARM action bit to trigger the scene but when I RUN this scene, the lights don’t stop flashing (assuming because the previous scene is still running in the background)… How can stop running the flash LUA script but triggered by the NONACTIVEALARM action bit??
Your help would be greatly appreciated!
thanks!
Add a Global Variable:
In the ON Scene LUA:
FLASH_ENABLE = true
In the OFF Scene LUA:
FLASH_ENABLE = false
Then modify the Off function to:
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="0" },13)
if (not FLASH_ENABLE) return
Im really ‘green’ in writing the LUA codes. Could you copy and paste my previous code and actually paste the variables in the right locations in the code? I would assume that the general variable in most codes are placed at the beginning but i’d like to make sure. And then you say modify the Off function, do you mean replace the function that is on the ON scene or OFF scene and am I adding this function or just modifying what is already there?
Here is what I would have done… (please comment and change if you don’t mind)
CODE FOR THE ON SCENE: (using no device buttons, only trigger from the alarm and this LUA code)
FLASH_ENABLE = true
function DipOnPorchLight(stuff)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },13)
if (sBlink == “1”) then
luup.call_timer(“DipOffPorchLight”, 1, “3”, “”, “”)
end
end
function DipOffPorchLight(stuff)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },13)
if (sBlink == “1”) then
luup.call_timer(“DipOnPorchLight”, 1, “3”, “”, “”)
end
end
if (sBlink == “1”) then
sBlink = “0”
else
sBlink = “1”
luup.call_timer(“DipOffPorchLight”, 1, “3”, “”, “”)
end
CODE FOR THE OFF SCENE: (again, using no device buttons, only trigger from the alarm and this LUA code)
FLASH_ENABLE = false
function DipOffPorchLight(stuff)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },13)
if (not FLASH_ENABLE) then
return
end
end
Thanks for all your help!!
I’m not sure if I completely fluked out, but those codes actually worked (using the run button to start the code). ‘On’ starts the blinking outside lights, ‘Off’ stops the flash loop and keeps the lights off. Now assuming the Triggers from the alarm panel are configured properly, if my alarm is tripped, the outside lights should flash on/off. If the alarm sends a not tripped trigger, the lights should stop flashing and stay off.
Thanks for all your help! ;D
oops … I forgot the then … end.
I work with a lot of different languages … they all look about the same to me … but all have their syntactic rules.
Glad it’s working.
Yeah, I tried it verbatim at first and I got an error. I figured out the “then” and “end”.
I tried to test the system by tripping my alarm and it worked except once I cleared my alarm, the lights stayed on (but the flashing stopped). I was wondering why?? Should I run the LUUP and use the device “OFF” button in the scene as well?? Maybe you can see why the light stays on when I’m calling an OFF command?
Thanks
You need the following:
ON Scene:
function DipOnPorchLight(stuff)
if (FLASH_ENABLE) then
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="1" },13)
luup.call_timer("DipOffPorchLight", 1, "3", "", "")
end
end
function DipOffPorchLight(stuff)
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="0" },13)
if (FLASH_ENABLE) then
luup.call_timer("DipOnPorchLight", 1, "3", "", "")
end
end
FLASH_ENABLE = true
DipOnPorchLight()
OFF Scene:
FLASH_ENABLE = false
The variable “sBlink” is a global variable, so is accessible in all scenes.
So you can stop this blinking simply by setting sBlink to “0” in your alarm stop scene. sBlink’s existence is for this very reason, and the “FLASH_ENABLE” variable is just duplicating sBlink’s function.
sBlink="0"
That is all that is needed. No reason to make this more complicated than it needs to be.
So are you saying that I don’t need the Flash Enable = false in my OFF scene, but only use your sBlink= 0 command?
Yes.
Thanks you so much! Works like a charm!
Thanks for this great example.
I do not have any problem starting the scene with the LUA.
However, I am not able to make the light stop flashing…
I have tried both:
FLASH_ENABLE = false
And
sBlink=“0”
I am running Vera Plus, does it make any difference?
Another question. For every time I want to use the flashing lights-code, do I need to run the whole code or is it enough with FLASH_ENABLE = true?
On my system, the (my original) blink code is associated with a scene (the scene does not do anything else).
When I want to start blinking, I run the scene. When I want to stop, I run the scene a second time. The second invocation of the scene will set sBlink to “0”, which will stop the blinking after the next iteration.
(Note that later suggestions just replaced sBlink with FLASH_ENABLE. Does pretty much the same thing. I did not see the need for two separate scenes, though.)
Does not matter what Vera box is being used.
I want to run LUA code when I activate the home mode (deactivating the flashing light).
Therefor I guess that I need 2 scene?
The idea is that the flashing light goes on when the alarm is activated.