Can't get this to work

Im trying to make automatic lights in my hallway. I’ve managed to get them to turn on as I want.

But I want the lights to turn of if there hasn’t been any motion for x minutes.

Triggers:
tHallTak the hallway light is on
tHallMotion motion detected

I’m trying this condition but the light never turns off:
tHallTak and (!tHallMotion; NOW > 2.00)

Have i misunderstood the whole thing or what am I doing wrong?

[quote=“jolerius, post:1, topic:185607”]I’m trying this condition but the light never turns off:
tHallTak and (!tHallMotion; NOW > 2.00)

Have i misunderstood the whole thing or what am I doing wrong?[/quote]

“(!tHallMotion; NOW > 2.00)” is a sequence expression, and works off timestamps. But you can only refer to the True timestamp. In other words, !tHallMotion does not return a timestamp.

So this could be written as “tHallTak and !tHallMotion and (tHallMotion; NOW > 2.00)”.

So logically - light is on and motion detector is not tripped and the last time it WAS tripped was over 2 minutes ago.

But you can only refer to the True timestamp. In other words, !tHallMotion does not return a timestamp.

That is not actually the case, @wilme2. The term !tHallMotion refers to the timestamp when tHallMotion last became false.

@jolerius, it would be helpful if you posted a PLEG Status report (in PDF form if possible) at the point where you think the light should have turned off automatically.

BTW: Did you mistype the expression tHallTak and (!tHallMotion; NOW > 2.00)? Check that you actually used tHallTak and (!tHallMotion; NOW > 2:00) - with a colon in the time not a period.

If you somehow turn the light on manually without tripping the motion detector … it will turn off within the next minute.

Man I have read every page of your PLEG primer a dozen times and hundreds of posts on PLEG, and never knew you could access the timestamp associated with the last false event. In fact I was convinced you couldn’t based on something I read. I bet I can optimize some logic now and cut down on triggers and conditions.

Sorry @jolerius if I confused you.

tried to change it to
tHallTak and (!tHallMotion; NOW > 2:00)

but when i try to flip the switch from within the web UI. It turns of again in 4 seconds?!?!
Se my attached status report

the condition is named cHallfivemin

when i try to flip the switch from within the web UI. It turns of again in 4 seconds?!?!

tHallMotion became false at 09:00:13 so when you turned on the light at 09:49:57, the Condition cHallfivemi became true and turned it back off.

If you want the auto-off to work only when motion has been detected, you could use something like this:

cHallfivemi tHallTak and (tHallTak; !tHallMotion) and (!tHallMotion; NOW > 2:00)

I don’t understand Condition cDoornomotion. It seems to turn the light on when the motion detector turns off. Is that what you wanted?

[quote=“RexBeckett, post:7, topic:185607”]tHallMotion became false at 09:00:13 so when you turned on the light at 09:49:57, the Condition cHallfivemi became true and turned it back off.

If you want the auto-off to work only when motion has been detected, you could use something like this:

cHallfivemi tHallTak and (tHallTak; !tHallMotion) and (!tHallMotion; NOW > 2:00)

I don’t understand Condition cDoornomotion. It seems to turn the light on when the motion detector turns off. Is that what you wanted?[/quote]

cDoornomotion is to turn on the lights, only when i open my door from outside.
So if the door opens before the motion detector detects motion then it should turn on the lights.

And then i want cHallFivemi to turn off my lights after two minutes. If there hasn’t been any motion in the hallway.
This i want to happen whenever the lights is turned on (by switch on wall, by cDoornomotion or by switch in UI)

So i would like cHallFivemi to allways turn the lights of if there hasn’t been motion in the hallway for 2 minutes.
And even if there hasn’t been motion after the light turned on, i want it to turn off after 2 minutes.

So if we come home and open the door, the light will turn on and stay on until we’re not moving in the hallway anymore. Wich usually means we are finished in the hallway and went to another room.
And if we turn the lights on in the morning to get dressed, i want it to stay on until we are no longer moving in the hallway. Wich means we have left the building. And after that i want the lights to turn off after 2 min. And if we forgot something and comes back within 2 minutes i want the lights to stay on until we stopped moving for 2 min again.

How do i achieve this?

I would use a SelfRetrigger timer (Schedule) for this. Something like:

Schedules
sLight2M OnType: SelfReTrigger, OffType: Interval, 00:02:00

Triggers
tDoor Whenever Hall mk is opened whether is armed or disarmed
tHallMotion Whenever the Hallmotion is turned on
tHallTak Whenever the Hall tak is turned on

Conditions
cDoornomotion No tDoor and !tHallMotion and !sLight2M
cStartTimer Yes tHallTak or !tHallMotion
cLightOff No tHallTak and !sLight2M and (tHallTak; !sLight2M)

Actions
cDoornomotion Hall tak SetLoadLevelTarget newLoadlevelTarget=100
cStartTimer PLEG StartTimer timerName=sLight2M
cLightOff Hall tak SetLoadLevelTarget newLoadlevelTarget=0

This assumes that your motion detector has a short on-time and that your light switch has an instant status report.

This assumes that your motion detector has a short on-time and that your light switch has an instant status report.

Well it seems to have a short on-time. Because it works like a charm now.
Have only tested it ont he webUI from remote tough.

No my switch do not have instant status report. It’s a normal switch connected to fibaro dimmer.

Another question: Instead of turning the lights on to max, can i set it to previous level?
like when i turn the wallswitch. It lights up to previos lightlevel

No my switch do not have instant status report. It's a normal switch connected to fibaro dimmer.

Fibaro dimmers do report instant status so that part should be OK.

Another question: Instead of turning the lights on to max, can i set it to previous level? like when i turn the wallswitch. It lights up to previos lightlevel

That is slightly more difficult. I don’t use any Fibaro dimmers so I can’t be sure but it may work if you use the SetTarget 0 and 1 action instead of the SetLoadLevelTarget 0 and 100. You would need to edit the Action using the Advanced tab.

If that doesn’t work, it may require some additional logic to save the previous dim level before turning it off.