CPrince Posted 18 hours ago Posted 18 hours ago I kind of get why this is happening but I don't. Just can't wrap my head around it. I thought of breaking it up into 2 programs but don't think that will work. I am looking to clean up this program. It works fine with the exception that it runs the “Else” part at 3:01 AM when I update my flag in another program. The flag is a heartbeat flag. If the flag stays the same, it still runs at 3:01 AM. These are unnecessary messages. I only wat the 8:55 and 5:55 message. My gate sensor does not have a heartbeat. It does have a Unix time stamp. So, I look to see if yesterday’s stamp is less than today’s stamp and if so, set my flag to 1. If not, I set it to 2. Gate Sensor Problem - [ID 0076][Parent 006C] If ( Time is 8:55:00AM Or Time is 5:55:00PM ) And ( $sSouthGate is not 1 Or $sNorthGate is not 1 ) Then Send Notification to 'Chris email' content 'Gate Sensor Problem' Wait 5 seconds Send Notification to 'Pushover' content 'Gate Sensor Problem' Wait 5 seconds Set 'Notification Controller / UD Mobile' Send Message Content 20 Notification ID (ID=20) Else Send Notification to 'Chris email' content 'Gate Sensor Normal' Wait 5 seconds Send Notification to 'Pushover' content 'Gate Sensor Normal' Wait 5 seconds Set 'Notification Controller / UD Mobile' Send Message Content 21 Notification ID (ID=21) Quote
larryllix Posted 12 hours ago Posted 12 hours ago (edited) Whatever your SouthGate or NorthGate does will trigger evaluation of your program. If anything triggers evaluation the two times with never be true and Else will always get run. Time triggers are always false unless THEY, THEMSELVES trigger the evaluation, even if the time is exactly the same time. Single time triggers cannot be used for logic filters. FIX? Change your NorthGate and SouthGate variabes to INTEGER types so they don't trigger your program, and only your times trigger it. Edited 12 hours ago by larryllix Quote
CPrince Posted 10 hours ago Author Posted 10 hours ago @larryllix Thanks. "If anything triggers evaluation the two times with never be true and Else will always get run." This is exactly where I got stuck and did not know how to fix. My problem is my lack of good knowledge of integer and state variables. I changed the $SouthGate and $NorthGate variables to integer. 1 Quote
Guy Lavoie Posted 9 hours ago Posted 9 hours ago Else statements that actually perform actions should be very rare. Usually they'll just do something like reset a variable. Quote
CPrince Posted 5 hours ago Author Posted 5 hours ago @Guy Lavoie I would agree. This code was left over from some old sensors with actual heartbeats. Rather than remove some in-depth code and rewrite some new code; I patched the old. I was being lazy. But at the same token it was why reinvent the wheel. I was like it is all here, just use the "Else"! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.