We have moved at community.getvera.com

Author Topic: [Code] WakeupRamp a device for ramping up a set of lights slowly  (Read 26983 times)

Offline ZMaF

  • Jr. Member
  • **
  • Posts: 50
  • Karma: +0/-0
[Code] WakeupRamp a device for ramping up a set of lights slowly
« on: February 16, 2011, 08:10:12 pm »
The attached files implement a binary device that I call WakeupRamp. I use it to slowly ramp up a set of lights in the morning. Since each family member wants different times for these lights, I created a device so I can easily have one per bedroom.

To use, upload the attached files via the UI and then create a device using:
device type : urn:schemas-upnp-org:device:BinaryLight:1
device file   : D_WakeupRamp.xml
impl file       : I_WakeupRamp.xml

Once you created the device you might have to refresh the settings to see the Advanced Device variables.

To configure, go to the advanced settings tab in the newly created device and scroll to the bottom:

Devices                : this is a list of device id's for the lights you want to ramp up
RampTimeSecs     : this is the ramp time in seconds (default 1800 = 30 minutes)
InhibitingDevices : this is a list of device id's that inhibit the ramping. I use this with virtual devices that are on say on vacation or if a particular person is sleeping in. (you can leave that blank)

Now, create a scene that will turn this wakeup ramp device on at the time you want the lights to start up. Since we get up at 6am, I have a scene that triggers weekdays at 5:30 and turns on my bedroom ramp device.

The code sends target levels to all devices in the list every 30 seconds or so, based on your ramp time and MaxLevel. You can set the MinInterval to something larger than 30 seconds.

The device will turn off automatically when the final light level is reached.

Vera2, ACT (8 switches, dimmers, 3-way, outlet), GE (15 dimmers, 3-way, outlets)

Offline jediobiwan

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
Re: [Code] WakeupRamp a device for ramping up a set of lights slowly
« Reply #1 on: February 16, 2011, 10:17:38 pm »
This is exactly what I was looking for! Thanks so much!

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: [Code] WakeupRamp a device for ramping up a set of lights slowly
« Reply #2 on: February 17, 2011, 04:23:16 am »
Thank you for sharing your code. Have you considered generalizing your Luup device (support for ramp up and ramp down)?

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: [Code] WakeupRamp a device for ramping up a set of lights slowly
« Reply #3 on: February 17, 2011, 05:02:19 am »
The attached files implement a binary device that I call WakeupRamp.

Pure genius.  Thanks for sharing such a useful plugin.

Offline ZMaF

  • Jr. Member
  • **
  • Posts: 50
  • Karma: +0/-0
Re: [Code] WakeupRamp a device for ramping up a set of lights slowly
« Reply #4 on: February 17, 2011, 07:53:40 pm »
Thank you for sharing your code. Have you considered generalizing your Luup device (support for ramp up and ramp down)?

I haven't had the need to do a ramp down, but this would be trivial to add (probably using a variable that specifies if you want to ramp down instead of up).

What scenario would you use this with?
Vera2, ACT (8 switches, dimmers, 3-way, outlet), GE (15 dimmers, 3-way, outlets)

Offline FIST

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
Re: [Code] WakeupRamp a device for ramping up a set of lights slowly
« Reply #5 on: February 17, 2011, 09:06:04 pm »
I could also use a "ramp down"

Situation:

For our "normal" day-to-day operations, I have some lamps in the living room at 75% dim level.

During scene "movie", I'd like them to be dimmed slowly down to 25% - like a movie theater does.

One of my considerations was taking whatever each current device's DimLevel was and reducing it from the current level. IE,somebody changed one lamp up to 100% DimLevel, so that one obviously has further to travel to 25%. But then I also was trying to figure out how to take a device that was off or at a lower dim level, and then dim that one up.

PhD level is to have that device ramp at a higher rate to achieve desired DimLevel at the same time.

So in short - I have a target dim level for all devices, take whatever level they're currently at, then slowly dim all devices up or down (independently, but at the same time) to reach the desired level.


Thanks for the code -- I had much much uglier Luup code to do the same thing.
« Last Edit: February 17, 2011, 09:17:27 pm by FIST »
Vera2 UI4 (1.1.1186), 3xVRI06, 1xVRI10, 4xVRS05, 3xVRS15, 2x VRF01, 5xVRP03, 2xTrane Therm, 2xAeon Labs Door/Window Sensor, 1xHSM100, 2xACT ZIR000, 1xForrezZ WWA-01, 2xGE 45613, 5x GE45606, 4xGE 45605, 2xGE 45604, 5xGE 45603, 4xGE 45602, 2xKwikset Deadbolts..

Offline futzle

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3260
  • Karma: +192/-9
Re: [Code] WakeupRamp a device for ramping up a set of lights slowly
« Reply #6 on: February 18, 2011, 04:10:55 am »
Hi ZMaF,

Here's a patch for a feature that I hope is useful.  It inverts the inhibition condition when you use a negative device number in the Inhibiting Devices list.

For example, a WakeupRamp device which has device 20 as an inhibitor will operate only when device 20 is "off".  A WakeupRamp device which has device -20 as an inhibitor will operate only when device 20 is "on".  This could be helpful when you want different WakeupRamp operations for each of the two states of device 20, or if device 20 has the "wrong" logic sense for what you need.

Code: [Select]
--- I_WakeupRamp_old.xml 2011-02-18 19:40:09.000000000 +1100
+++ I_WakeupRamp.xml 2011-02-18 19:50:33.000000000 +1100
@@ -84,7 +84,7 @@
 
   function toListOfNumbers(s)
      t = {}
-     for v in string.gmatch(s, "([0-9]+)") do
+     for v in string.gmatch(s, "(-?[0-9]+)") do
        table.insert(t, tonumber(v))
      end
      return t
@@ -132,10 +132,15 @@
    -- check here to see if any inhibiting devices are on and stop
    for index = 1, #data.inhibitingDevices, 1 do
      local device = data.inhibitingDevices[index]
+     local invert = false
+     if (0 > device) then
+       device = 0 - device
+       invert = true
+     end
 
      local inhibitor, lastSet = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", device)
 
-     if (inhibitor == "1") then
+     if (inhibitor == (invert and "0" or "1")) then
        -- turn off wakeup
        luup.variable_set("urn:upnp-org:serviceId:SwitchPower1","Status",0,lul_device)
        return

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: [Code] WakeupRamp a device for ramping up a set of lights slowly
« Reply #7 on: February 18, 2011, 04:36:48 am »
Quote
I haven't had the need to do a ramp down, but this would be trivial to add (probably using a variable that specifies if you want to ramp down instead of up).

What scenario would you use this with?

Save energy: Ramp down the outdoor light until civil twilight sets in. Could be implemented with a combination of your WakeupRamp plugin and my DAD plugin.

Offline ZMaF

  • Jr. Member
  • **
  • Posts: 50
  • Karma: +0/-0
Re: [Code] WakeupRamp a device for ramping up a set of lights slowly
« Reply #8 on: February 18, 2011, 11:00:37 am »
@futzle, that's a great addition. I was planning to allow something like that, but your solution seems cleaner than another list variable I had planned.

As for ramping down, one thing to note is that this works for slow ramping only. If you want smooth ramping over a short time ( < 1 minute), this kind of approach probably won't work, because the Zwave communication is too slow (or Vera is).

If you want ramping over short periods of time, you should program the rate and step options on the dimmers and then dim to the target level. I haven't played with that, but I'm sure it's doable.
Vera2, ACT (8 switches, dimmers, 3-way, outlet), GE (15 dimmers, 3-way, outlets)

guest10984

  • Guest
Re: [Code] WakeupRamp a device for ramping up a set of lights slowly
« Reply #9 on: March 30, 2011, 06:08:36 pm »
Is there anyway someone could explain how to set this up in language that someone who's never done this before?  I got as far as uploading the file, but when I tried to create the device I got lost.

Offline shady

  • Hero Member
  • *****
  • Posts: 1331
  • Karma: +11/-0
  • This monkey knows his Window Coverings!
Re: [Code] WakeupRamp a device for ramping up a set of lights slowly
« Reply #10 on: March 31, 2011, 03:23:19 pm »
When you go to create a device, you just fill in this information under the device's advanced tab, then close and save.

-To use, upload the attached files via the UI and then create a device using:
-device type : urn:schemas-upnp-org:device:BinaryLight:1
-device file   : D_WakeupRamp.xml
-impl file       : I_WakeupRamp.xml
-
-Once you created the device you might have to refresh the settings to see the Advanced Device variables.

you might have to refresh/save in the UI to see the device in the UI (sometimes it isn't instant)
If you need it, hopefully I can write you more of a walkthrough when I get home later and try to add this device myself.
Vera3 1.5.346, Schlage (3)DB (2)Lever, Kwikset (1)Lever, RCS TZ43 Thermo, (2) Vizia RZI06-1LX 600W Dimmers, (17) Monster (Leviton) Dimmers (6) Monster (Leviton) IWC Scene Controllers (1) Etherrain-8, (3) HSM 100's (1)GE 3-Way set

guest10984

  • Guest
Re: [Code] WakeupRamp a device for ramping up a set of lights slowly
« Reply #11 on: April 01, 2011, 04:17:13 pm »
I got it working, it was the refreshing after creating the device that I was forgetting.  The code works great, but when I use the default 30 min ramp up time I get some weird flickering with my light at about 50% power.  Changing the time to 20 minutes eliminates the flickering.  Any ideas what could be causing it?  It's a standard 100w incandescent bulb

Offline ZMaF

  • Jr. Member
  • **
  • Posts: 50
  • Karma: +0/-0
Re: [Code] WakeupRamp a device for ramping up a set of lights slowly
« Reply #12 on: April 05, 2011, 11:06:03 am »
My guess would be that the flickering is caused by your dimmer module at a particular dim setting. When you change it to 20minutes, that particular dim level may not be reached (skipped).

I have been using it on ACT dimmers and HomeSetting lamp modules without flickering.
Vera2, ACT (8 switches, dimmers, 3-way, outlet), GE (15 dimmers, 3-way, outlets)

Offline S-F

  • Hero Member
  • *****
  • Posts: 1248
  • Karma: +62/-12
  • Clueless N00b
Re: [Code] WakeupRamp a device for ramping up a set of lights slowly
« Reply #13 on: December 12, 2011, 04:45:50 am »
Looks like UI5 broke this one.

UI 5 sucks. This is complete BS. I wish I had gone with HomeSeer instead of Vera. I have a server that's on all the time any way. I would switch but I already spent the money on Vera. WTF? I just can't believe this. MCV had better fix all of the problems they have created with this new trash.
« Last Edit: December 12, 2011, 05:05:34 am by S-F »
My forum account was apparently hacked by a leprechaun. And he's drunk all of the time. If a post of mine seems a little off kilter, it's probably because he made it.

Offline kgrr

  • Full Member
  • ***
  • Posts: 155
  • Karma: +0/-0
  • My obsession: Totally automating my townhouse
Re: [Code] WakeupRamp a device for ramping up a set of lights slowly
« Reply #14 on: January 08, 2012, 03:35:58 pm »
...I wanted to chime-in with FIST's earlier comment:

Quote
I could also use a "ramp down"

Situation:

For our "normal" day-to-day operations, I have some lamps in the living room at 75% dim level.

During scene "movie", I'd like them to be dimmed slowly down to 25% - like a movie theater does.

One of my considerations was taking whatever each current device's DimLevel was and reducing it from the current level. IE,somebody changed one lamp up to 100% DimLevel, so that one obviously has further to travel to 25%. But then I also was trying to figure out how to take a device that was off or at a lower dim level, and then dim that one up.   ...

While dining out, I've found it disturbing to a conversation when the light level changes suddenly.  I definitely can see situations where it would be nice to not only ramp-up and ramp-down lights slowly besides for waking up.  For example, the ramp function may be used in a living/dining area to raise the lights in the afternoon to maintain light levels while the sun is setting quickly.  But then, later on as the evening progresses, it may useful to set the lights back down for evening entertainment and dining.  At the end of the evening party, it may be useful to slowly raise the light levels so that guests can find their car keys and the rest of their belongings, but not to be so obvious in kicking them out ;) 

---------------------
Vera2 (1.5.255, UI5); ACT ZRW113W; Aeon HEM, SmartSwitch, GE/Jasco 45600, 45601, 45602, 45603, 45604, 45605, 45606, 45609, 45614; Hawking HRDS1; Intermatic CA9000; Schlage BE369GR, WCE100; SQ Blaster Plus; Squeezebox; Trane TZEMT400AB32MAA