One more time… any thoughts? It’s a complete rewrite using all the feedback. Tests seem successful. No errors.
.Help with Garage Door Auto Close
Lookin’ good! I believe you actually incorporated all of my tips!
Single trigger
No loops
No commands sent which would restart the piston
No spanning midnight
No triggers
indented
Well done.
Although, I would consider allowing lines 27-43 to run 24 hours a day.
(and only placing a restriction on the final IF at lines 44-57)
IE:
IF {DoorPositionOpen} is true
and
{GarageLightOn} is false
and
Time is not between sunrise and sunset
Then ...
I do have two other thoughts in the back of my mind, but no need to mention them if things are working well for you.
How is changing the time restriction beneficial? Is it to keep the boolean values from potentially being out of sync?
In the interest of education, what are your thoughts?
Absolutely.
Lets say Contact Sensor 1 or 2 is opened at 5pm… Maybe a cleaning day or whatever.
Lets say the sun sets at 5:30… The door is still open…
The variables
would not be updated until the next cycle.
My advice would be to keep the variables
accurate 24/7, but restrict the actions based on time or whatever.
Pro Tip:
Dropping the ONLY WHEN
also allows you to insert a Time trigger
, to re-sync. Maybe something like:
IF Time happens daily at sunset + 2 minutes
Then Log to console "Sun setting" (Anything can go here. It's just a forced trigger)
END IF
Keeping in mind that this will also recheck your last piston lines 37 onwards.
(well, if ONLY WHEN is removed, that is)
Okay… You asked for it… LOL. Just kidding
(1) is simply dropping the ONLY WHEN
, as somewhat mentioned above…
(IF conditions
are almost always preferred)
(2) is more of a curiosity…
I wonder if one of these devices:
- Switch 6
- Door 1
- Door 2
will do something that will change either:
Contact Sensor 1’s contact
- or -
Contact Sensor 2s contact
(perhaps you see where I am heading with this, )
I think I see what you’re asking and I aborted the previous idea as the risk vs reward wasn’t favorable.
The piston is as you see it.