Question re light operation

Wanting to move my “smart” home to an automated home I’ve installed PLEG and starting to do some first sequences.

I have a question as I don’t believe I’m doing this correctly.

Firstly my scenario - currently I have a scene which Vera runs to turn light A on at sunset, this is set to come on at 50% dim.

That is fine as when I get home Vera runs a “home” scene which turns light A up to 100%. Now the problem I am trying to work around is that if I’m at home with light A already on, come sunset Vera sets Light A to 50%.

I’m hoping with Pleg I can check the status of Light B and if light B is off set light A to 50%, if light be in on then do nothing or set light A to 100% (as both would be the same).

I have so far set up a condition in schedule in PLEG to run at the required time and two conditions based on the status of Light B (>5% and = 0). Currently this means light A behaves inline with the Condition of Light B but not just at the required time, it does it all the time. The other thing is that if I turn off Light B to 0 then light A will come on to 50%.

How do I get this to just happen at the required time and the ignore it again, Is it a stop type ? (I understand if no stop type is set then it will only run once).

Do I delete the current scene and run this totally in PLEG ?.

I’m pleased I’ve got

In essence I want if light B = 0 then light a 50%, if light B = >5% then light A = 100%. I only want that at a certain time but I seem to be going around in circles to get to it.

If someone can give me a nudge in the right direction I would be most grateful.

First of all…abandon the native scenes and move to PLEG completely. As you are learning, the native scenes don’t allow you to use conditional logic easily…these scenes just always run unless you want to write custom lua code.

If you don’t already have it, you will want to create a virtual switch to indicate whether you are home or not. When you return home or leave, have your return/exit logic set this switch to the appropriate state. PLEG can then use the state of this switch to change behavior depending on whether you are home or not. I recommend you use MultiSwitch - it will give you 8 virtual switches in one device (I use it for things like Home/NotHome, OnVacation, Christmastime, etc.)

Once you have that, you can create some simple PLEG logic. It sounds like your desire to check the status of Light B is really a work around to know if you are home or not. If so, you can just use the virtual switch for your Home/NotHome status and avoid checking the other light.

Triggers:
tAtHome MultiSwitch Switch 1 is turned on (this is a virtual switch that indicates whether you are home or not)

Schedules:
sEvening create a schedule that turns on at sunset, turns off at 22:30:00 or whatever time you want

Conditions:
TurnOnLightWhenNotHome NOT tAtHome AND sEvening --when you’re not home and sunset arrives
TurnOnLightWhenHome tAtHome AND sEvening --this will turn on light at sunset when you are home, or as soon as you return home after sunset
TurnOffLight NOT tAtHome OR NOT sEvening --if it is not evening, or you leave the house

Actions:
TurnOnLightWhenNotHome set your light to 50%
TurnOnLightWhenHome set your light to 100%
TurnOffLight turn off light

If you really want to use the state of Light B to control Light A, add a trigger for when Light B is turned on (tLightBOn) and then update the Conditions to get the behavior you want (e.g. replace tAtHome with tLightBOn for the simplest method, you can add logic to get more fancy)

Does that help?

Thank you, that is exceptionally helpful!.

It’s clear I need to think about the performing of things in a different way to how I was, the need to have something that is “true” or “False” is what I was missing, I had the light performing based on the status of the other but not in line with how I wanted it.

I will start with making a home / away status (I can control that easily with the nest app and tasker) and run the light as you suggest. From there I will build it a little further so that light A does check light B as this will mean the lights can then still come on at 50% dim even when I am home but not in the room.

Thanks again for your help, now to go and have a play :slight_smile:

After some tweaking I’ve just been dancing around like a lunatic as this is now working.

“light A” are window lights that come on for security hence when I leave in the evenings I like these to still be on but drop back down to 50%, removing Turnofflight was all that was needed to get this working like a dream.

That makes things much neater than the way I had to achieve the same before so I’m looking forward to seeing how this will work for other scenes.

Thanks again for the help, I had my lightbulb moment with it (no pun intended).