Hello
I have never used PLEG before and always just used code snippets off the forum. I have a new Vera Edge I am transferring too and would like to now use and learn PLEG. I have installed the Program Logic Core and the Program Logic Event Generator plug-ins.
I am wanting to create my first pleg that is based on an existing scene on my old VeraLite. The scene checks to see if a virtual switch is turned on, if it is then it gets the status of the curtains to see if they are already open? If they are, it runs a scene to close the curtains. The trigger for the scene is my Kodi PC starting to play a Movie.
Link_KODI_to_devices = luup.variable_get(“urn:dcineco-com:serviceId:MSwitch1”,“Status1”,44) – Is the MultiSwitch Switch 1 = ON
if(Link_KODI_to_devices==“0”)then return false end – If its OFF end and do nothing
are_curtains_open = luup.variable_get(“urn:upnp-org:serviceId:Dimming1”,“LoadLevelStatus”,70) – If its ON get status of curtains
if(are_curtains_open==“100”)then – If the curtains are OPEN then run a scene to close the curtains
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”,“RunScene”,{SceneNum=“31”},0)
end
Scene Trigger = Player State Changes → Video Starting
and also in the trigger of this old scene I also had some additional LUUP code to check it is night time
if ( luup.is_night() ) then
return true
else
return false
end
I would like to do all this in a PLEG, here is what I have setup but its not working as expected:
PLEG-1.png
Trigger = Kodi PC starts playing Video
PLEG-2.png
Device Properties
- Curtains_Status ?
0 = Closed / 100 = Open - Is_Night ?
Day and Night plug-in 0 = Night / 1 = Day - Kodi_Linked ?
MultiSwitch Status1 - 0 = Off (Not Linked) / 1 = On (Linked)
PLEG-3.png
Conditions
Its Night time and Kodi is Linked (Switch1 = ON) and Curtains are already open
Is_Night==0 and Kodi_Linked==1 and Curtains_Status==100
PLEG-4.png
Actions
Device = Lounge Curtains
Device Action = Down (I couldn’t see Close or Open in the actions list so used down which closes the curtains).
Here is what happens, the curtains are open, it is night here now and the Kodi PC is not playing anything and its status is Video_Stop and the MultiSwitch Switch1 is OFF.
If I then turn on MultiSwitch Switch1 to ON (meaning this links Kodi to Vera) the curtains then close right away.
They should not close when I turn on or off Switch1. They should only close when Kodi starts playing a Video.
Also whilst the PLEG is armed and the MultiSwitch Switch1 is ON, I cannot just operate the curtains device in the Vera GUI normally and press the Open button, the curtains don’t open, they do close however using the close button.
I have to either bypass the PLEG or turn off the Switch1 and then the Open command on the curtain device works as it should.
I guess it can only be my Conditions which are wrong.
Any ideas?
Thanks