Automatic kitchen light

So I have some downlights inside a cabinet with glass doors.
I have mounted a magnetic switch to the doors and the downlights is also remote controlled.

I am trying to have the lights turn on automatically if they were off, and turn off after 30 seconds if they were turned on automatically.
It is the last part I am strugeling with. The lights keep turning off after I have opened the doors.
Have tried with different logic but I get errors when saving. I am trying to tie the off command to the on condition, but I dont know how…
Anyone have a sugestion to a syntax that will work?

regards,

Below is a copy from the status info in the pleg.

Triggers

Name Description Last Trigger State
SkapOpen Skapsensor kj?kken armed is tripped 2013-10-20 14:30:10.938 false
SkapNotOpen Skapsensor kj?kken armed is not tripped 2013-10-20 14:30:12.507 true
Device Properties

Name Device Name Device Variable Last Change Value
SkapLysStatus Spotter skap Status 2013-10-20 14:31:41.356 0
Conditions

Name Expression Last True State
LightOn SkapLysStatus < 1 and SkapOpen 2013-10-20 14:30:10.939 false
LightOff SkapNotOpen AND (SkapNotOpen; NOW > 00:30) 2013-10-20 14:31:39.107 true

If you change to match the following condition you should get what you want. But, if you were more specific with what hardware you are using, such as the magnetic switch, we may be able to make this more interesting.

[tt]LightOff SkapNotOpen AND (LightOn; NOW > 00:30)[/tt]

Actually you want:
LightOff SkapNotOpen AND (SkapNotOpen; NOW > 00:30) and (SkapOpen;LightOn)

The first part of the condition turns the light off somewhere between 30 and 90 seconds after the door is closed … that second part says the light must have been turned on After the door was opened, i.e. it was auto opened.

[quote=“RichardTSchaefer, post:3, topic:177438”]Actually you want:
LightOff SkapNotOpen AND (SkapNotOpen; NOW > 00:30) and (SkapOpen;LightOn)

The first part of the condition turns the light off somewhere between 30 and 90 seconds after the door is closed … that second part says the light must have been turned on After the door was opened, i.e. it was auto opened.[/quote]

The second part definitely did the trick. It works exactly as intended now.
I regularly want the light to turn on when open the cupboard. but not when I have set the light via a scene that includes the lights in the cupboard. Perfect!

I am for information using fibaro dimmer and door window sensor.

After some time I have come across an instance where this does not work exactly as I want it to.

If I open the door to take out a glass the light turns on. If I close the door, and then open it again before the light turned off it will not turn off automatically.
I guess because the “SkapOpen;LightOn” expression is no longer satisfied. I am not sure if there is a way around this? The most important is that the logic doesn’t turn off the light if it was turned on manually (by switch, remote etc…).

any thoughts?

I have made some modifications that I hope i can include in the pleg.
The kitchen cabinet has another set of doors, that are covered by the same light.
2 doors and 4 down lights. 2 down lights in each cabinet. When I began this project I only had one magnetic sensor.
I have now added a second sensor, so that I have sensors on all doors for the cabinet.

But I have run in to some challenges setting this up in PLEG. See below for status from pleg, and my attempt to set up a logic. Do you have any comments or thoughts? (I have deleted the part of the status report that does not concern the cabinet logic)

Triggers

Name Description Last Trigger State

SkapOpen Skapsensor kj?kken is tripped 2013-11-25 21:49:53.109 false
SkapNotOpen Skapsensor kj?kken is not tripped 2013-11-25 21:49:56.559 true
SkapLysOff Spotter skap is turned off 2013-11-25 20:31:42.968 true
Skap2Open Skapsensor2 is tripped 2013-11-25 20:32:39.538 false
Skap2NotOpen Skapsensor2 is not tripped 2013-11-25 20:32:42.728 true

Conditions

Name Expression Last True State
LightOn (SkapOpen or Skap2Open) and SkapLysOff 2013-11-24 12:19:35.892 false
LightOff Skap1or2Closed AND (Skap1or2Closed; NOW > 00:30) and ((SkapOpen;LightOn) or (Skap2Open;LightOn)) 2013-11-25 10:00:12.120 false
Skap1or2Closed SkapNotOpen or Skap2NotOpen 2013-11-25 20:28:17.087 true

Actions

Actions for Condition: LightOn
Immediate

Device Action Arguments
Spotter skap SetLoadLevelTarget newLoadlevelTarget=40

Actions for Condition: LightOff
Immediate

Device Action Arguments
Spotter skap SetLoadLevelTarget newLoadlevelTarget=0

I would attack this problem as follows:
Only need the tripped triggers.
You can delete all of the NOT TRIPPED triggers (unless you want them for the status report).

I would create two new conditions at the beginning:

AnySkapOpen Skap1Open OR Skap2Open OR SKap3Open
AllSkapClosed (Not Skap1Open) AND (Not Skap2Open) AND (Not Skap3Open)

Then in the original logic where you referenced the SkapOpen replace with AnySkapOpen
and replace any NOT SkapOpen with AllSkapClosed

After some struggling I got this to work.
Had to tweak it a bit to get i to fire. Remove and add the trigger, not sure why that made any difference. But it works now…
Thanks for your help!

I have an instanse where this logic does not do exactly as I was hoping for. If I open the door to take out a glass the light turns on. If I close the door, and then open it again before the light turned off it will not turn off automatically.
I guess because the "SkapOpen;LightOn" expression is no longer satisfied. I am not sure if there is a way around this? The most important is that the logic doesn’t turn off the light if it was turned on manually (by switch, remote etc…).

Do anyone have any thoughts?

Sent from my iPad using Tapatalk

Can you post a status report when this happens so we can see your current setup and the state it’s in.

Hi,
I have removed the part of the pleg that is not relevant for the automatic kitchen lights.
Here is the status report from today:

Smartlys

Device ID: 1882014-01-04 13:25:01.990 PLC Version: 5.5

Triggers

Name Description Last Trigger State

Skap1Open Skapsensor kj?kken is tripped 2014-01-04 12:56:18.574 false
Skap2Open Skapsensor2 is tripped 2014-01-04 12:25:36.881 false

Device Properties

Name Device Name Device Variable Last Change Value
SkapLysStatus Spotter skap Status 2014-01-04 12:56:07.682 1

Conditions

Name Expression Last True State
AnySkapOpen Skap1Open OR Skap2Open 2014-01-04 12:56:18.590 false
AllSkapClosed (NOT Skap1Open) AND (NOT Skap2Open) 2014-01-04 12:56:27.462 true
LightOn AnySkapOpen and (SkapLysStatus < 1) 2014-01-04 12:56:07.434 false
LightOff AllSkapClosed AND (AllSkapClosed; NOW > 00:30) and (AnySkapOpen;LightOn) 2014-01-04 10:57:08.123 false

Actions

Actions for Condition: LightOn
Device Action Arguments
Spotter skap SetLoadLevelTarget newLoadlevelTarget=40

Actions for Condition: LightOff
Immediate
Device Action Arguments
Spotter skap SetLoadLevelTarget newLoadlevelTarget=0

Do you think you have any suggestions? This is large problem with the logic, and if it is not possible to solve with logic, I think it is better to just have a simple timer that turns off the light after X seconds.
The problem with this is if the light is used in a scene. It will turn off every time the the doors are closed.

thanks for your help.
regards

I am giving this a go agin. Since I still am scratching my head trying to figure this out.
My problem with this logic is that if I open the doors before the light turns off automatically, it will not turn off automatically.

The condition I am using is as follows:
AllSkapClosed AND (AllSkapClosed; NOW > 00:30) and (AnySkapOpen;LightOn < 5)

I think that when I reopen the door before it is auto turned off the “(AnySkapOpen;LightOn < 5)” part of the condition is no longer satisfied.
But I dont know how I could get around this.

any thoughts?

regards