Hi,
I’m trying to get my first PLEG script (?) working and was hoping for some help and/or insight from other users here.
What I have is a Fibaro RGBW controller to dim some LED strips in a cabinet. This works flawlessly when controlling manually. I also have a light sensor which seems to have a life of its own, but…at least it’s reporting something and should be good for testing.
My goal is to set the SetLoadLevelTarget of the Fibaro equal to the amount of light the sensor detects. The sensor seems to go from 0-100, which works nicely with my idea of automagically dimming the lights so that they don’t blind you. If the ambient light is very low, the light in the cabinets should be low as well. Just for the fun of it I also tried making another trigger to only do this if the light is less than 70 (I probably need to turn this down, and I probably have to play around with the loadlevel, too). Now, I was hoping to get this to always set the loadlevel to the ambient light level detected. This doesn’t seem to be the case. I’ve set the light sensor to report back every 60 seconds hoping that even if I set the LEDs to 100%, they would be dimmed down within a minute.
This is what I’ve done for my first test:
[ul][li]Program Logic Event Generator->Inputs->Device properties->Name: LightLevel_Living_room, Device Name: _LightSensor, Device Variable: CurrentLevel, Current Value: 2[/li]
[li]Program Logic Event Generator->Conditions->Condition Name: LightHigh, Condition Expression: LighLevel_living_room > 70[/li]
[li]Program Logic Event Generator->Conditions->Condition Name: LightLow, Condition Expression: LighLevel_living_room < 70[/li]
[li]Program Logic Event Generator->Actions->Conditions:LightLow, # of Actions:LUA;Immegiate - 0-> (the LightHigh is very similar, so I won’t bother pasting it in)[/li]
[li][/li][/ul]
[code]local Light_Status_Ikea = luup.variable_get(“urn:schemas-upnp-org:device:DimmableLight:1”, “Status”, 234)
local Light_Status_Vitrine = luup.variable_get(“urn:schemas-upnp-org:device:DimmableLight:1”, “Status”, 240)
local Light_level = luup.variable_get(“urn:micasaverde-com:serviceId:LightSensor1”, “CurrentLevel”, 237)
if tonumber(Light_Status_Ikea) > 0 then – is ‘==1’ possible?
luup.call_action(“urn:schemas-upnp-org:device:DimmableLight:1”, “SetLoadLevelTarget”, {newLoadlevelTarget = Light_level}, 234)
end
if tonumber(Light_Status_Vitrine) > 0 then
luup.call_action(“urn:schemas-upnp-org:device:DimmableLight:1”, “SetLoadLevelTarget”, {newLoadlevelTarget = Light_level}, 240)
end[/code]
Now, if I execute manually it works but they’re not being set automagically. The PLEG device is armed.
Do I need to set an interval for this? I was hoping it would pick up on when the variables changed.
Thanks!