Blinking Light??

I’ve been unsucessfully trying to script a scene to make a blinking light. I’ve searched the forum and found a couple of examples, did exactly like they said on each and I still get a luup error. I’m new to vera and luup but I understand code logic but I can’t figure out why it won’t work. Can someone maybe figure out what I’m doing wrong?

I tried using these two examples
http://forum.micasaverde.com/index.php/topic,9364.msg67349.html#msg67349
http://forum.micasaverde.com/index.php?topic=5127.0

I’m using a vera lite with UI5 and the light is hooked up to a regular non-dimmer z-wave light switch. The device ID is 19.

Any help would be appreciated. Thanks!

Also tried this one… http://forum.micasaverde.com/index.php?topic=3015.0 which happens to have the same device ID. Also doesn’t work. It says “Starting scene execution” but nothing happens. Also tried a different device. Still nothing.

All three of the examples should work provided:

[ul][li]You set the device ID to match your switch. This is the number at the top of the Advanced tab.[/li]
[li]You paste the code into the scene’s LUUP tab.[/li]
[li]You ensure that there are no extraneous characters copied with the code.[/li][/ul]

Post the exact code you are using - between the code tags that appear when you click the # button.

I have been using this for my blinking lights. I created a scene and set this up to have 8 of my lights blinking. Run this scene a second time to stop the blinking.

function DipOnPorchLight(stuff)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },226)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },310)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },306)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },336)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },212)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },337)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },340)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },341)
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” },226)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },310)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },306)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },336)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },212)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },337)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },340)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },341)

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

[quote=“RexBeckett, post:3, topic:186436”]All three of the examples should work provided:

[ul][li]You set the device ID to match your switch. This is the number at the top of the Advanced tab.[/li]
[li]You paste the code into the scene’s LUUP tab.[/li]
[li]You ensure that there are no extraneous characters copied with the code.[/li][/ul]

Post the exact code you are using - between the code tags that appear when you click the # button.[/quote]

We’ll go with this one since it already has the same device number.

I double checked the device number. At the top of the advanced tab it says Device#19.

I created a new scene with nothing in it except this code which I did paste into the luup tab.

This is exactly what was pasted into the lump section.

function DipOnPorchLight(stuff)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },19)
if (sBlink == “1”) then
luup.call_timer(“DipOffPorchLight”, 1, “1”, “”, “”)
end
end
function DipOffPorchLight(stuff)
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },19)
if (sBlink == “1”) then
luup.call_timer(“DipOnPorchLight”, 1, “1”, “”, “”)
end
end
if (sBlink == “1”) then
sBlink = “0”
else
sBlink = “1”
luup.call_timer(“DipOffPorchLight”, 1, “1”, “”, “”)
end

I cannot see if there any odd characters in the lines. That is only possible when you use the code tags. Try the code below. I have extended the times to three seconds. One second may not be enough time for the Z-Wave commands to get through your network.

function DipOnPorchLight(stuff) luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="1" },19) 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" },19) 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

Nope. Still didn’t work. I pasted your code into the window, saved, and tried to run the scene. Again, it says executing but nothing happens. I understand the time duration being an issue but it’s pretty instantaneous when I turn the light on and off on the local network. Didn’t work with the longer duration either.

Is there anything in the veralite that I should check? Some kind of setting to check?

I also tried some luup settings for day and night for an outside light that didn’t work. So far I haven’t been able to get any luup codes to work.

So far I haven't been able to get any luup codes to work.

So there is something wrong with how you are doing it. Try this:

Paste the code into APPS → Develop Apps → Test Luup code (LUA). Then click the GO button. Your lights should start to flash. Clicking GO again should stop them.

That works! And I copied the code straight from the luup tab in the scene and pasted it into the develop apps tab.

So I deleted my scene and made a new one. Pasted the code into the luup tab and nothing. :(. Still doesn’t work. Am I doing something wrong with the scene? Here’s what I did…

I click New Scene, Give it a name, click the luup tab, paste the code, click Save lua, confirm changes, and save in the top right corner. Then I wait for the “unit busy” to clear, and click Run on the scene. It says starting scene execution but nothing happens.

Got it figured out!!! There was a constant message in my status window at the top center of the page that said “error in lua for scenes and events”. So I started checking my other scenes for code. Voila! I had a test scene that I’d made for another light that had some bad syntax in it. I deleted the scene and now my blinking lights scene works!!!

I would have never guessed that an error in an unrelated scene would affect another one. Thanks for showing me the develop app tab. That helped point me in the right direction.

I’m glad to hear that it is working now. The Lua code in all scenes runs in the same context. If Vera finds an error while it is loading the code, it will not run any of it.

Using the same context - also shared with Startup Lua - can be useful but requires some care. Global variables and functions defined in one piece of code are visible to all others.

The Blink code has global functions (DipOnPorchLight & DipOffPorchLight) and a global variable (sBlink). If you use the code in multiple scenes it will interact unless you change the names of the global items for each new use.