We have moved at community.getvera.com

Author Topic: Blinking Christmas tree  (Read 28208 times)

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Blinking Christmas tree
« on: December 24, 2010, 09:47:08 am »
Happy Christmas!

Code: [Select]
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()

Offline mysticjay

  • Full Member
  • ***
  • Posts: 184
  • Karma: +1/-1
Re: Blinking Christmas tree - Multiple devices and return to original status
« Reply #1 on: October 25, 2011, 07:19:44 pm »
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.

Code: [Select]

--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()

« Last Edit: October 25, 2011, 07:23:07 pm by mysticjay »
Vera 2 (1.1.1338), Trane TZEMT400BB3,ML IWD600S(2), ML IWS1000S(2) , FI8905W, Aeon DSB04100-ZWUS, GE 45609(2), GE 45606(2), GE 45608, GE 45614 (5), LFM-20(2), Kwikset 99100-011 (5) , Hawking HRMD1, Droid X and Xoom as Remotes, Harmony Link

Offline Canadian EC

  • Jr. Member
  • **
  • Posts: 94
  • Karma: +0/-0
Re: Blinking Christmas tree
« Reply #2 on: March 04, 2012, 08:08:10 pm »
Does the syntax in this code work in UI5?

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.

What I am I doing wrong?

Offline Canadian EC

  • Jr. Member
  • **
  • Posts: 94
  • Karma: +0/-0
Re: Blinking Christmas tree
« Reply #3 on: March 07, 2012, 04:10:49 pm »
anybody?

Offline Da_JoJo

  • Hero Member
  • *****
  • Posts: 1380
  • Karma: +16/-78
  • If something aint work, we can allways try n make
Blinking Christmas tree dimmer version
« Reply #4 on: March 14, 2012, 08:38:32 pm »
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...
Code: [Select]
-- 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()
« Last Edit: March 15, 2012, 08:07:44 am by Da_JoJo »
Vera lite (1.5.622), 2x an-158/2, dead usb pl2302 rs-232, 2x greenwave 6 port, 4x Fibaro FGD211 v1.6, FGBS001, few FGS - 221, etc. AuthomationHD 3 for android :-)
Dutch & German translator http://wiki.micasaverde.com/index.php/Special:AllPages http://support.micasaverde.com http://domotica-shop.nl

Offline oTi@

  • Community Beta
  • Master Member
  • ******
  • Posts: 4041
  • Karma: +32/-6
  • UI what ?!
Re: Blinking Christmas tree
« Reply #5 on: March 14, 2012, 09:58:38 pm »
Does the syntax in this code work in UI5?
It (i.e. the code from @mysticjay's post) appears to work for me (Vera 2 and Vera 3, UI5; appliance module and dimmer).
Dezwaved at the moment...

Offline Da_JoJo

  • Hero Member
  • *****
  • Posts: 1380
  • Karma: +16/-78
  • If something aint work, we can allways try n make
Re: Blinking Christmas tree
« Reply #6 on: March 14, 2012, 10:06:39 pm »
could you test mine ? i got no dimmer device to test it on lol
Vera lite (1.5.622), 2x an-158/2, dead usb pl2302 rs-232, 2x greenwave 6 port, 4x Fibaro FGD211 v1.6, FGBS001, few FGS - 221, etc. AuthomationHD 3 for android :-)
Dutch & German translator http://wiki.micasaverde.com/index.php/Special:AllPages http://support.micasaverde.com http://domotica-shop.nl

Offline oTi@

  • Community Beta
  • Master Member
  • ******
  • Posts: 4041
  • Karma: +32/-6
  • UI what ?!
Re: Blinking Christmas tree
« Reply #7 on: March 14, 2012, 10:23:47 pm »
could you test mine ?
You may want to update with MCV's creative argument naming (newLoadlevelTarget).
And perhaps provide a description in the post of what this code does differently (compared to @Ap15e and @mysticjay).
« Last Edit: March 15, 2012, 07:28:54 am by oTi@ »
Dezwaved at the moment...

Offline Da_JoJo

  • Hero Member
  • *****
  • Posts: 1380
  • Karma: +16/-78
  • If something aint work, we can allways try n make
Re: Blinking Christmas tree
« Reply #8 on: March 15, 2012, 05:16:08 am »
could you test mine ?
You may want to update with MCV's creative argument naming (newLoadlevelTarget).
And perhaps provide a description in the post of what this code does differently (compared to @Ap15e and @mysticjay).
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.
« Last Edit: March 15, 2012, 07:29:10 am by oTi@ »
Vera lite (1.5.622), 2x an-158/2, dead usb pl2302 rs-232, 2x greenwave 6 port, 4x Fibaro FGD211 v1.6, FGBS001, few FGS - 221, etc. AuthomationHD 3 for android :-)
Dutch & German translator http://wiki.micasaverde.com/index.php/Special:AllPages http://support.micasaverde.com http://domotica-shop.nl

Offline oTi@

  • Community Beta
  • Master Member
  • ******
  • Posts: 4041
  • Karma: +32/-6
  • UI what ?!
Re: Blinking Christmas tree
« Reply #9 on: March 15, 2012, 07:25:30 am »
im not sure what u mean by the creative argument naming ?
Your code contains: newLoadLevelTarget
Vera listens to: newLoadlevelTarget
Dezwaved at the moment...

Offline Da_JoJo

  • Hero Member
  • *****
  • Posts: 1380
  • Karma: +16/-78
  • If something aint work, we can allways try n make
Re: Blinking Christmas tree
« Reply #10 on: March 15, 2012, 08:00:46 am »
aight... i see the capitalize is the problem  thnx  ;D
fixed post
Vera lite (1.5.622), 2x an-158/2, dead usb pl2302 rs-232, 2x greenwave 6 port, 4x Fibaro FGD211 v1.6, FGBS001, few FGS - 221, etc. AuthomationHD 3 for android :-)
Dutch & German translator http://wiki.micasaverde.com/index.php/Special:AllPages http://support.micasaverde.com http://domotica-shop.nl

Offline Da_JoJo

  • Hero Member
  • *****
  • Posts: 1380
  • Karma: +16/-78
  • If something aint work, we can allways try n make
Blinking Christmas tree looped dimmer version
« Reply #11 on: March 15, 2012, 08:33:40 am »
Code: [Select]
-- 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()

and this ?
Vera lite (1.5.622), 2x an-158/2, dead usb pl2302 rs-232, 2x greenwave 6 port, 4x Fibaro FGD211 v1.6, FGBS001, few FGS - 221, etc. AuthomationHD 3 for android :-)
Dutch & German translator http://wiki.micasaverde.com/index.php/Special:AllPages http://support.micasaverde.com http://domotica-shop.nl

Offline oTi@

  • Community Beta
  • Master Member
  • ******
  • Posts: 4041
  • Karma: +32/-6
  • UI what ?!
Re: Blinking Christmas tree
« Reply #12 on: March 15, 2012, 09:04:00 am »
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 delay 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. :)

« Last Edit: March 15, 2012, 09:16:53 am by oTi@ »
Dezwaved at the moment...

Offline Da_JoJo

  • Hero Member
  • *****
  • Posts: 1380
  • Karma: +16/-78
  • If something aint work, we can allways try n make
Re: Blinking Christmas tree
« Reply #13 on: March 15, 2012, 09:57:16 am »
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 delay 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. :)
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 :)
Vera lite (1.5.622), 2x an-158/2, dead usb pl2302 rs-232, 2x greenwave 6 port, 4x Fibaro FGD211 v1.6, FGBS001, few FGS - 221, etc. AuthomationHD 3 for android :-)
Dutch & German translator http://wiki.micasaverde.com/index.php/Special:AllPages http://support.micasaverde.com http://domotica-shop.nl

Offline Da_JoJo

  • Hero Member
  • *****
  • Posts: 1380
  • Karma: +16/-78
  • If something aint work, we can allways try n make
Re: Blinking Christmas tree
« Reply #14 on: March 15, 2012, 10:51:01 am »
Code: [Select]
-- 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()
how bout this lol
« Last Edit: March 15, 2012, 10:56:35 am by Da_JoJo »
Vera lite (1.5.622), 2x an-158/2, dead usb pl2302 rs-232, 2x greenwave 6 port, 4x Fibaro FGD211 v1.6, FGBS001, few FGS - 221, etc. AuthomationHD 3 for android :-)
Dutch & German translator http://wiki.micasaverde.com/index.php/Special:AllPages http://support.micasaverde.com http://domotica-shop.nl