I’d like to replace the WakeupLight plugin, since it’s been pretty dormant (very functional, but dormant) for a while, so I was wondering if anybody have a recipe for how to ‘ramp up’ a dimmer over a period of time - for instance 10 minutes - by using PLEG instead.
Well, this isn’t using PLEG, but you can do this with the lua below…just insert it into a scene. Change the first four variables to suit your needs. The DimDeviceID is the vera ID of the dimmer you want to change. TotalMinutes is the total length of time (in minutes) you want to take to ramp up the light to the final level. UpdatePerMinute is how often per minute you want the ramp level to change. And EndRamp is the final ramp level (in percent). (The code will get the current level of your light first, and begin ramping from that level.)
This will ramp lights up as well as down depending on the EndRamp value that you set, as well as what the light is currently at when you execute the code.
So in the below example, Dimmer 102 will ramp up to 100% over a period of 1 minute by increasing it’s ramp 10 times per minute.
Not ever having used PLEG myself, I would be curious as to how this would be done using it.
Note: depending on how your specific light device works, a switchpower1 status change update may also be needed to actually turn the light on. If the below doesn’t work let me know.
DimDeviceID = 102
local UpdatePerMinute=10
local TotalMinutes = 1
local EndRamp =100
function SetRamp(newTarget)
local param={}
param = {newLoadlevelTarget=tonumber(newTarget)}
luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",param,DimDeviceID)
end
local InitRamp = luup.variable_get("urn:upnp-org:serviceId:Dimming1","LoadLevelStatus",DimDeviceID) or 0
local StepSize = (EndRamp - InitRamp) / (UpdatePerMinute * TotalMinutes)
local TheLevel = 0
for i=1,TotalMinutes *UpdatePerMinute,1 do
TheLevel= InitRamp + StepSize * i
CallInterval = math.floor((60 / UpdatePerMinute) * i)
luup.call_timer("SetRamp",1,tostring( CallInterval ),"",tostring(TheLevel))
end
Thanks @JoeyD.
The LUA approach is simple enough and this gives me something to work from in order to try and generate a condition tree for PLEG that would let me ramp.
Off-hand, I’m thinking it may be possible with self-triggering schedules and using variables to hold dimmer state, ramp steps, etc. But I’m a bit swamped for time so I don’t have time to experiment right now.
I want a light to ramp up over a matter of seconds (maybe 5 or 10 seconds) to give my eyes a little bit of a chance to adjust. How would I modify this code to do that?