Announcement

Collapse
No announcement yet.

Jon00's POP3 + Heartbeats?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Jon00's POP3 + Heartbeats?

    Hi Jon00 or anyone who can help.

    I run the POP3 script from Jon00, and use this to email me when I get a fire call that relates to me. I discovered lately that they have a heartbeat system, and thought it would be good to implement that in this system as well. Basically the system sends a message that contains "QD1200 baud heartbeat" and the pager decoder system picks that up. What i would like to do is have a script / message that runs when that message is emailed to me, so that if the message is NOT emailed to me within 1 - x hours, it sends me an email saying the system may not be functioning.

    Does anyone have any ideas, I have no problems setting devicestring from Jon00's POP3 script and the trigger script, however i am not sure how to set a script or event to fire when the device is NOT updated within x hours.

    Thanks for any help!!
    HS3 PRO, Win10, WeatherXML, HSTouch, Pushover, UltraGCIR, Heaps of Jon00 Plugins, Just sold and about to move so very slim system.

    Facebook | Twitter | Flickr | Google+ | Website | YouTube

    #2
    OK, lets have a first stab at this!

    Create a virtual device and call it something like 'Fire pager heartbeat'. Set the type as 'status only'. For the sake of example, lets say that this device has a device code of 'a99'

    If I remember correctly, you are using the txt version of the trigger script.

    Just above the 'end sub' in this script, add the following code:

    PHP Code:
    If Instr(1,MailText,"QD1200 baud heartbeat",1) > 0 then
    hs
    .SetDeviceString "a99""Fire pager heartbeat received at " now(), True
    hs
    .SetDeviceValue "a99"1
    end 
    if 
    Now create a script called Fireheartbeat.vb with the following code:

    PHP Code:
    Sub Main(ByVal Parm As Object)

    Dim DC As String "a99"
    Dim MinuteTrigger As Integer 60
    Dim lastdate 
    As Date hs.DeviceLastChange(DC)
    Dim t As TimeSpan DateTime.Now.Subtract(lastdate)
    If 
    t.TotalMinutes >= MinuteTrigger and hs.DeviceValue(DC) <> 0 then
        hs
    .SendEmail("To_emailaddress@123.com","From_emailaddress@123.com","Heartbeat warning""Fire heartbeat has not been detected" )
        
    hs.SetDeviceValue (DC0)
    end if

    End Sub 
    Save this in the scripts directory. Create a recurring event to run this script say every 15 minutes.

    Set the To_emailaddress and From_emailaddress to suit your details.
    Set the MinuteTrigger to the number of minutes before the email is sent without a heartbeat email.

    If everything is working correctly with a heartbeat received, the virtual device a99 will show the updated time/date.

    If this update stops then the script will email you once after XX minutes. It should reset itself if the pager messages resume.
    Jon

    Comment


      #3
      Thanks Jon00,

      As always your self-taught skills are nothing short of amazing and very helpful!
      I made a slight modification and included a twitter message in the script so it will twitter me, and since i have the twitter client running on my iphone, its a free notification service which is more timely than email.

      Works a treat.
      HS3 PRO, Win10, WeatherXML, HSTouch, Pushover, UltraGCIR, Heaps of Jon00 Plugins, Just sold and about to move so very slim system.

      Facebook | Twitter | Flickr | Google+ | Website | YouTube

      Comment


        #4
        Once again Jon00 thanks for all of your work, They system is up and running and occasionally (depending on my reception) My phone will beep with "Pager connectivity down, check receiver" through Mokosus's Twitter script.

        Thanks again for all your help, I can account the higher WAF in my house to many of your scripts!
        HS3 PRO, Win10, WeatherXML, HSTouch, Pushover, UltraGCIR, Heaps of Jon00 Plugins, Just sold and about to move so very slim system.

        Facebook | Twitter | Flickr | Google+ | Website | YouTube

        Comment


          #5
          Thanks!
          Jon

          Comment

          Working...
          X