Garage Automation Example

I’ve been learning about PLEG and wanted to share my garage automation which I now have working. I originally had a lot of questions and things took a while to understand so thought that sharing my experiences would help out others.

I have a garage and a connected shop, each with a connected dimmer module and motion sensor. I also have a contactor connected to the garage door button and a tilt type garage door sensor.

There are several objectives:

  1. Close garage door if left open and if the garage is not occupied for more than a certain period.
  2. Automatically turn on garage light when I enter the garage, and then turn on the shop light if I go to the shop.
  3. Be able to turn off the lights manually at any time.
  4. Automatically turn off lights if left on and garage is unoccupied for more than a certain period.
  5. Utilize the garage door plugin which greatly simplifies the door operation.

Inputs

GarageDoorIsOpen = true if garage door plugin is unlocked
NoGarageMotion = sensor is not tripped
NoShopMotion = sensor is not tripped
GarageMotion = sensor is tripped
ShopMotion = sensor is tripped
ShopLightOn = light is turned on
ShopLightOff = light is turned off
GarageLightOn = light is turned on
GarageLightOff = light is turned off

Conditions

GarageIsUnoccupied = NoGarageMotion and NoShopMotion and (NoGarageMotion;NOW>5:00) and (NoShopMotion;NOW>5:00)
CloseGarageDoor = GarageDoorIsOpen and (GarageDoorIsOpen;NOW>5:00) and GarageIsUnoccupied
GarageReady = GarageMotion;NoGarageMotion
ShopReady = ShopMotion;NoShopMotion
TurnGarageOn = GarageLightOff and GarageMotion and GarageReady
TurnShopOn = ShopLightOff and ShopMotion and ShopReady

Actions

GarageIsUnoccupied = turn off both lights
CloseGarageDoor = lock garage door plugin to activate door close procedure
TurnGarageOn = turn on garage light
TurnShopOn = turn on shop light

Basically, everything seems to work as expected… Other things I am thinking about but could use input on:

Retry two times at 10 minute intervals and then notify me if door is still open.

Some notable things I learned in this automation:

  1. Simply stating the sequence NoXMotion;NOW>M:SS is insufficient to extend the time if occupied. My sensor stays triggered for 4 minutes and then needs to be triggered again. The above would be true M minutes after the reset turning the light of while the room may still be occupied. Therefore, “and NoXMotion” is needed to make the expression failsafe.
  2. I needed to add an expression that indicates that the garage door should have been open for more than 5 minutes. Otherwise it may close immediately after opening when a car arrives. (Wife comes home.)
  3. Needed to include the “ready” logic to only allow a light to turn on automatically after the motion detector resets it’s state. Otherwise the light would turn back on immediately after I tried to turn off manually.
  4. the garage door plugin rocks!
  5. PLEG is awesome once you figure out the behavior.

Interested in any expert feedback on better ways of implementation and other ideas people have done or would recommend or like to see me try.

Cheers!

PD

The statements:
GarageReady = GarageMotion;NoGarageMotion
ShopReady = ShopMotion;NoShopMotion

Are equivalent to:
GarageReady = NoGarageMotion
ShopReady = NoShopMotion

As a result you can Eliminate those conditions and just use NoGarageMotion and NoShopMotion in your subsequent conditions.

And I can’t see how your shop and Garage lights work since your expressions are equivalent to:

TurnGarageOn = GarageLightOff and GarageMotion and NoGarageMotion
TurnShopOn = ShopLightOff and ShopMotion and NoShopMotion

If it’s working your lucky because I have an inefficiency in handling two input triggers from the same device property.

Thanks for reviewing this…

The reason I put the whole ready logic was to avoid the scenario where I can’t manually turn off a light while the sensors have not reset. So, there must be a race condition that is turning out ok.

To make it more robust should I do:

TurnGarageOn = GarageLightOff and GarageMotion and (NoGarageMotion;NOW>0:05)

Sometimes I’m in the garage for just a very short time and would like to turn off the light manually very soon after it turns on. Is there a better logic to use?

Also, any suggestions for how to approach the retry several times to close the door and then notify if unsuccessful functionality?

Thanks!

PD

Maybe something like:

TurnGarageOn = GarageLightOff and (GarageLightOff; GarageMotion > 5:00)
TurnShopOn = ShopLightOff and (ShopLightOff; ShopMotion > 5:00)

So motion 5 minutes after the lights were last turned off will cause the lights to come back on.