PLEG Example: Garage Door Autoclose using 3 Sensors (Ultrasonic, Beam, Door)

Hi Guys,

I’ve recently “upgraded” my garage automation to replace dodgy vision tilt sensors, with wired Reed switches and IR Beams. Using the Qubino Flush 1 relays as they have the additional sensor inputs.

The IR beams span the garage door entrances, and the idea is to use them as a means of preventing garage door closing if something is in the way, and as a trigger alert if the garage door is left open and someone comes in (or a dog tries to escape). This probably requires status variables or virtual motion sensors but I’m not sure how to go about it.

In pseudo code I’d like to get:

  1. If Beam Broken continuously for more than 3 seconds then alert that door is obstructed. Clear alert when beam has been clear for 3 seconds.

  2. Alert that the beam has been momentarily broken once, no matter how many times broken within a 3-5 second period (legs, groups walking through at once, produces only one trigger alert). Clear the alert after beam has been unbroken for 3 seconds.

They may be the same thing… Thoughts/suggestions greatly appreciated.

Solution: http://forum.micasaverde.com/index.php/topic,36017.msg329105.html#msg329105

Vera is not Vera reliable handling evens that are seconds apart.

Hi Richard,

You’re absolutely correct, however I’m trying to get Vera to ignore any messages it gets in a short space of time rather than act on them.

So perhaps my logic needs to be more like:

On first trip, set a status, then ignore any other changes until a timer expires and then clear the status?

[quote=“BlueSmurf, post:3, topic:190816”]Hi Richard,

You’re absolutely correct, however I’m trying to get Vera to ignore any messages it gets in a short space of time rather than act on them.

So perhaps my logic needs to be more like:

On first trip, set a status, then ignore any other changes until a timer expires and then clear the status?[/quote]

That would be very easy to make a timer, use the timer in the condition “!timer” and what ever the first action is also have it start the timer (self tripping) and it won’t go true again until that timer runs down.

PLEG can handle the syntax … and the processing … I am not sure how reliable Vera will See to many events in a matter of seconds.
There is lag time in the Z-Wave network … There is lag time in Vera procesing … PLEG wll run within 10 milliseconds of Vera detecting the change.

Doing a bit of Necromancy here, as my ultrasonic parking sensor had stopped working. But back on track.

I figure I need 3 conditions to get this to work, and then a way of tying the conditions together.

So far I have

[code]cGarage_Open_Car_Parked tGarage_Main_Open AND tCar_Parked

cCar_Clear !tCar_Parked AND !tGarage_Main_Beam_Triggered AND (!tCar_Parked; !tGarage_Main_Beam_Triggered < 10)[/code]

I’m thinking that cGarage_Open_Car_Parked should then initiate a timer which or maybe set a counter to 1? This is basically arming the door autoclose mechanism.

cCar_Clear has been working pretty reliably in my testing (surprisingly). Basically the car goes and the beam is then clear. If that happens in order within 10 seconds, then it means the car has reversed out and is clear of the beam.

Now I need a 3rd condition that says if the timer is active (or the counter is 1), and if cCar_Clear is true then close the door but only if the beam is still clear.

Any suggestions on best way to do the ‘priming’. Counter, Timer, State Variable?

Ok, after a bit of playing around I settled on using a counter - xGarage_AutoClose_Primed

Triggers
tCar_Parked Whenever Parking Status is opened whether is armed or disarmed
tDoor_Main_Closed Whenever Door Sensor - Main is closed whether is armed or disarmed
tDoor_Main_Open Whenever Door Sensor - Main is opened whether is armed or disarmed
tGarage_Main_Beam_Triggered Whenever Beam Sensor - Main detects motion whether is armed or disarmed

Counters
xGarage_AutoClose_Primed Ordinal

Conditions
cGarage_Open_Car_Parked tDoor_Main_Open AND tCar_Parked AND (tCar_Parked; tDoor_Main_Open )
cCar_Clear !tCar_Parked AND !tGarage_Main_Beam_Triggered AND (!tCar_Parked; !tGarage_Main_Beam_Triggered < 10)
cGarage_Main_Closed tDoor_Main_Closed
cGarage_AutoClose (xGarage_AutoClose_Primed != 0) AND cCar_Clear

Actions
cGarage_Open_Car_Parked Logic - Geo Security IncrementCounter counterName=xGarage_AutoClose_Primed counterIncrement=1
cGarage_Main_Closed Logic - Geo Security ClearCounter counterName=xGarage_AutoClose_Primed
cGarage_AutoClose Garage Door - Main SetTarget newTargetValue=1

Notes:

  • “Garage Door - Main” is a Garage Door Plugin instance (Lock Device), which has a magnetic sensor “Door Sensor - Main” for identifying if the door is open or not. Connected to the I2 input on a Qubino Single Relay module
  • “Parking Status” is a Mysensors Arduino Ultrasonic Sensor similar to: Parking Sensor | MySensors - Create your own Connected Home Experience
  • “Beam Sensor - Main” - is an IR Beam sensor with a relay, connected to the I3 input on a Qubino Single Relay module.