Here is a thread for working PLEG code that may be improved. What is considered an improvement is highly subjective of course.
Here is my scenario:
I have armed my postbox with a micro switch detecting when someone (hopefully the mailman) opens the lid and deliver the snail mail. Switch 8 on a multiswitch panel indicates new mail or when the postbox has been emptied. By clicking the multiswitch panel, I can manually set new mail or emptying the mail. When I empty the postbox I simply open and close the lid 3 times within 15 seconds.
Here is the code:
Triggers
postBox PostBox armed is tripped
postButton MultiSwitch Panel Switch 8 is turned on
Schedules
mailTime Weekly:1,2,3,4,5 None Weekly:1,2,3,4,5
Conditions
UnsetPostButton postButton and (postButton;postBox) and (postBox @ 3 < 0:15)
SetPostButton !postButton and postBox and mailTime and (UnsetPostButton; postBox > 1:00)
AnnounceEmptied !postButton
PostAnnounce postButton
PostBoxSabotage postBox and !mailTime
Actions
UnsetPostButton Multiswitch Panel SetStatus8 newStatus8=0
SetPostButton Multiswitch Panel SetStatus8 newStatus8=1
AnnounceEmptied Vera Alerts message
PostAnnounce Vera Alerts message
PostBoxSabotage Vera Alerts message