local device = 16834
local counter = 10
local delay = 3
function tree_on()
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="1" },device)
luup.call_delay( 'tree_off', delay )
end
function tree_off()
counter = counter-1
if counter > 0
then
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="0" },device)
luup.call_delay( 'tree_on', delay )
end
end
tree_off()
Here’s a version based on Ap15e’s that lets you blink multiple lights - and puts them back to their original status after the counter reaches its max.
--Enter the device ID's here in the array with your device id's
local array_lights = {1,2,3}
local original_status={}
local counter = 10
local delay = 3
function set_switch(device,value)
luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue=value },device)
end
function tree_on()
for i, device in ipairs(array_lights) do
set_switch(device,"1")
end
luup.call_delay( 'tree_off', delay )
end
function tree_off()
counter = counter-1
if counter > 0 then
for i, device in ipairs(array_lights) do
set_switch(device,"0")
end
luup.call_delay( 'tree_on', delay )
else
--Set to original status
for i, device in ipairs(array_lights) do
set_switch(device,original_status[i])
end
end
end
--Save Original status
for i, device in ipairs(array_lights) do
original_status[i] = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status", device)
end
tree_off()
I tried this out with my dimmable light (device Id: 3) and the server just tells me there’s a LUA error.
Or am I not entering it correctly?
I tried at first just creating a new scene and pasting the code in with “3” instead of the “16834” and then tried by creating the scene, clicking the device to go to 100%, and then pasting the code in.
im waiting on this 6 outlet controllable device , when i get it finally (back-orderded and need te be made first at plant etc) i write something for this to control 6 lights or so… i have nothing to test code on so it need to wait
if anyone is bored , he could write a piece to make us happy.
lemme see…
-- set device <id> of dimmer here without < >
local device =<the device-id of the dimmer>
local counter=10
local delay=3
local mindim=0
local maxdim=100
function tree_on()
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadlevelTarget",{ newLoadlevelTarget=maxdim },device)
luup.call_delay( 'tree_off', delay )
end
function tree_off()
counter = counter-1
if counter > 0
then
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadlevelTarget",{ newLoadlevelTarget=mindim },device)
luup.call_delay( 'tree_on', delay )
end
end
tree_off()
You may want to update with MCV’s creative argument naming ([tt]newLoadlevelTarget[/tt]).
And perhaps provide a description in the post of what this code does differently (compared to @Ap15e and @mysticjay).
You may want to update with MCV’s creative argument naming ([tt]newLoadlevelTarget[/tt]).
And perhaps provide a description in the post of what this code does differently (compared to @Ap15e and @mysticjay).[/quote]
im not sure what u mean by the creative argument naming ?
description is it does same as Ap15e version but this one sets loadlevel for dimmers… thought it might be nice add-on. the ultimate plan was to make it blink like a star.
-- code for dimmer to make it a automated blinking christmas tree light.
-- set device <id> of dimmer here without < >
local device =<the device-id of the dimmer>
local counter=10
local delay=3
local mindim=0
local maxdim=100
function tree_on()
for i,maxdim
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadlevelTarget",{ newLoadlevelTarget=i },device)
end
luup.call_delay( 'tree_off', delay )
end
function tree_off()
counter = counter-1
if counter > 0
then
for i,mindim,-1
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadlevelTarget",{ newLoadlevelTarget=i },device)
end
luup.call_delay( 'tree_on', delay )
end
end
tree_off()
Haven’t tested it, but note that dimmers typically ramp up/down to the target level autonomously, rather than having to create a Z-Wave storm with unknown timing to do that. So depending on the settings of the dimmer, there is a minimum value for the [tt]delay[/tt] parameter.
In other words: your initial code creates the pulsar you were looking for, if dimensioned correctly.
[quote=“oTi@, post:13, topic:167189”]Haven’t tested it, but note that dimmers typically ramp up/down to the target level autonomously, rather than having to create a Z-Wave storm with unknown timing to do that. So depending on the settings of the dimmer, there is a minimum value for the [tt]delay[/tt] parameter.
In other words: your initial code creates the pulsar you were looking for, if dimensioned correctly.
Probably time for you to order that dimmer. :)[/quote]
lol
ima getting it next month probably, when i have figured out what i want … i just need a good reason to buy the aeon dimmer with energy-measuring… somehow it seems useless to have measurement on the device as it uses 16 watts or 0 and i can type that in the vera. on the other hand there only 5 € more expensive then this fibaro which on its turn probably fits better in my ceiling box. i could also put a raiser between the existing switch… i dont wanna rush things and find out it lacks functionality…
also figured according to what you say about the timing… it must be very hard to get this in reality on the right pace, since its structural design isnt really capable and furthermore the dimmer itself can have a ramp like u say. hence testing irl is required
-- code for multiple dimmers to make a top-notch christmas tree
--Enter the device ID's here in the array with your device id's
local array_dimmers={2,3,4}
local original_status={}
local counter = 10
local delay = 3
local dimmin=0
local dimmax=100
function set_switch(device)
for i,dimmin do
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadlevelTarget",{ newLoadlevelTarget=i },device)
end
for i,dimmax,-1 dimmax do
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadlevelTarget",{ newLoadlevelTarget=i },device)
end
end
function tree_on()
for i, device in ipairs(array_lights) do
set_switch(device)
end
luup.call_delay( 'tree_off', delay )
end
function tree_off()
counter = counter-1
if counter > 0 then
for i, device in ipairs(array_lights) do
set_switch(device,"0")
end
luup.call_delay( 'tree_on', delay )
else
--Set to original status
for i, device in ipairs(array_lights) do
set_switch(device,original_status[i])
end
end
end
--Save Original status
for i, device in ipairs(array_lights) do
original_status[i] = luup.variable_get("urn:upnp-org:serviceId:Dimming1","SetLoadlevelTarget",{ newLoadlevelTarget=status },device)
end
tree_off()
[quote=“Da_JoJo, post:15, topic:167189”][code]
– code for multiple dimmers to make a top-notch christmas tree
–Enter the device ID’s here in the array with your device id’s
local array_dimmers={2,3,4}
local original_status={}
local counter = 10
local delay = 3
local dimmin=0
local dimmax=100
function set_switch(device)
for i,dimmin do
luup.call_action(“urn:upnp-org:serviceId:Dimming1”,“SetLoadlevelTarget”,{ newLoadlevelTarget=i },device)
end
for i,dimmax,-1 dimmax do
luup.call_action(“urn:upnp-org:serviceId:Dimming1”,“SetLoadlevelTarget”,{ newLoadlevelTarget=i },device)
end
end
function tree_on()
for i, device in ipairs(array_lights) do
set_switch(device)
end
luup.call_delay( ‘tree_off’, delay )
end
function tree_off()
counter = counter-1
if counter > 0 then
for i, device in ipairs(array_lights) do
set_switch(device,“0”)
end
luup.call_delay( ‘tree_on’, delay )
else
–Set to original status
for i, device in ipairs(array_lights) do
set_switch(device,original_status[i])
end
end
end
–Save Original status
for i, device in ipairs(array_lights) do
original_status[i] = luup.variable_get(“urn:upnp-org:serviceId:Dimming1”,“SetLoadlevelTarget”,{ newLoadlevelTarget=status },device)
end
tree_off()
[/code]
how bout this lol[/quote]
This code returns a LUUP code error for me. I am using the US version of vera3 with the latest firmware…
Just trying to get ready for christmas…LOL
Can anyone spot syntax error?
replace : local array_dimmers=
with : local array_lights=
sorry for the late response
didnt see that one as the programming language gimme headaches sometime
feel free to ask if it still gives errors so it can be fixed