Really Struggling

I am trying to get my En-suite lights to turn off after a set period of time and currently the lights turn on but don’t turn off. Its also slowed my Vera down to a restart so i wonder if i have messed up the code. I have attached the output of the status of the PLEG Device hoping that somebody can verify what i have done wrong.

The PIR triggers for 2 minutes (tESMotion) then resets after this time with no motion detected, so i expected the timer to start then.

I have a garage door closer working just fine in PLEG but this is using NOW and not a call to the StartTimer so i wonder if i have made a mistake there? for the life of me i cannot figure out the issue with the lights.

I am using the Vera Edge on Firmware 1.7.1320

Any help would be greatly appreciated.

I think it is a bit overly complex. Suggestion:

cESMotionDetected No tESMotion (Likely want to turn repeats on here)
cESAutoOn No !tESLightsOn and cESMotionDetected
cESAutoOff No (tESLightsOn; !sESTimer3)

Actions for Condition: cESMotionDetected
Program Logic Core StartTimer timerName=sESTimer3 intervalTime=

Actions for Condition: cESAutoOn
Lights SetTarget newTargetValue=1

Actions for Condition: cESAutoOff
Ensuite Lights SetTarget newTargetValue=0

If you want to get fancier later, add in a manual operation detection condition, but for now get the automation working first…

Hi wilme2

Thank you for your support its really appreciated.

I just want to clarify something

When you state No in the following statement did you mean to?

cESMotionDetected No tESMotion (Likely want to turn repeats on here)
cESAutoOn No !tESLightsOn and cESMotionDetected do you mean i put the not
cESAutoOff No (tESLightsOn; !sESTimer3)

I have tried it without the No command and it seems that anything to do with the timer isn’t working. I have used the sESTimer3 again as i removed the En-suite sensors and added them to a smart switch for now. So the prefix of everything has changed to


For my office lights

I have attached the status report again, and you can see that even though i have triggered the the lights with the PIR it doesn’t seem to fire the schedule.

Currently the lights fire up, but don’t switch off.

Again thanks for the help.


I meant cESMotionDetected should likely be Yes for repeats. And that is what you have in your PLEG Lights3.pdf file, so good.

But you changed from cES to sOF, so I am a little confused. Right now you are setup to turn on the “Office ceiling” via cOFAutoOn, but there is no Action associated with cOFAutoOff.

I think I see the real issue, however - in the action to start the timer - that device should be “PLEG Lights” not “Program Logic Core”.

You’re an absolute star thank you, it was because i was calling the Pleg Core as opposed to the Pleg Lights, School boy Error.

I would have been scratching my head for quite a long time looking for that.

So the lights come on when triggered by motion and go off after 3 minutes as expected, however when the light is switched on at the light switch the lights don’t go off after the set period.

What do you reccommend regarding the cAutoOff Condidion as i currently have (tOFLightsOn; !sESTimer3) and i guess i need to incoporate

Thanks Again

Does the switch support instant status? ( or Z-Wave Smart Dimmers, Switches & Fan Controllers | HomeSeer) If not, you would have to accept it might take time for Vera to know it has been switched on. If it is communicating directly with Vera you might not notice, but worst case you might have to wait for a poll if it routed across the network…

Generally when I write manual switch logic, it is because I want a light to stay on/off longer than the automatic setting. Meaning ignore the automation for a period of time (like an hour) before going back to automatic mode. But if you want the switch to follow its 3 minute timer, then you just need to start the timer when you see the lights turn on.

So (for example) a new condition cOFLightOn that also starts the sESTimer3 timer.

Or a little cleaner you could combine:

cOFMotionOrManual Yes tOFMotion or tOFLightsOn
cOFAutoOn No !tOFLightsOn and tOFMotion
cOFAutoOff No (tOFLightsOn; !sESTimer3)

Condition: cOFAutoOn
Office ceiling SetLoadLevelTarget newLoadlevelTarget=35
Condition: cOFAutoOff
Office ceiling SetLoadLevelTarget newLoadlevelTarget=0
Condition: cOFMotionOrManual
Device Actions:
PLEG Ligths StartTimer timerName=sESTimer3 intervalTime=

Yes all my switches support instant on and show the correct status in the UI as they trigger.

You have got me thinking about the manual timer part, could you share the code you use for the different timer for manual activation to motion

I like the idea of passing through the room and the lights having a quick time out on motion, however having the option to manually switch on the switch so it stays on for 30 minutes would be perfect.

The office scenario is perfect for this as i can be pretty stationary and with it being a battery PIR as i had to use this until Vera sort the compatibility for the universal sensor from fibaro i cannot relay on the fact that it will trip in the 3 minutes i give it.

I don’t want to be constantly waving my hands around to re trigger the timer, although that wouldn’t have been an issue until you came along, as there was a lot of arm waving i can assure you. :slight_smile:

I generally use this format below, which was inspired by some of Richard’s examples.

First I establish what is manual operation - lights turning on or off that are not as a result of an automation (based on if they happened within 30 seconds of an automation) - and if that is the case, start a 1 hour timer. During that 1 hour I leave the lights in the state their are in, once it expires I go back to automatic.

Then I set up the auto on and auto off logic. There is a chicken or egg issue, since the conditions refer to each other and one has to be written first, but it is easy when you plan it out.

Condition: FirstFloorBathroomSinkLightsManualOperation Yes (NOT (FirstFloorBathroomNeedsSinkLightsOn; FirstFloorBathroomSinkLightsOn < 30) and FirstFloorBathroomSinkLightsOn) or (NOT (FirstFloorBathroomNeedsSinkLightsOff; !FirstFloorBathroomSinkLightsOn < 30) and !FirstFloorBathroomSinkLightsOn)

Condition: FirstFloorBathroomNeedsSinkLightsOn No !FirstFloorBathroomSinkLightsOn and FirstFloorBathroomOccupancy and (FirstFloorBathroomSinkLightsManualOperation;!FirstFloorBathroomSinkLightsManual1H) and NOT QuietTime

Condition: FirstFloorBathroomNeedsSinkLightsOff No FirstFloorBathroomSinkLightsOn and !FirstFloorBathroomOccupancy and (!FirstFloorBathroomDoorClosed or (FirstFloorBathroomDoorClosed and (FirstFloorBathroomDoorClosed; !FirstFloorBathroomDoorClosed1H))) and (FirstFloorBathroomSinkLightsManualOperation; !FirstFloorBathroomSinkLightsManual1H)

Richard’s original example, which doesn’t return to automatic after a period of time…,12759.msg109850.html#msg109850

Thank you, you have saved me a lot of time and frustration, its really appreciated.

I will take a look at the thread now, now i using the correct timer trigger.

I can see what all the fuss is about this Plugin, it really can bring Vera to another level.

Kind regards