Jump to content

Program running unexpectedly.


Recommended Posts

Posted

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)

 

Posted (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 by larryllix
Posted

@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.

  • Like 1
Posted

@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"!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

    • There are no registered users currently online
  • Forum Statistics

    • Total Topics
      38.1k
    • Total Posts
      380.4k
×
×
  • Create New...