Announcement

Collapse
No announcement yet.

HS4 Internet Monitoring

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

  • 123qweasd
    replied
    Thanks for the feedback, glad it worked out.
    Cheers,
    ​​​​​​

    Leave a comment:


  • Tomgru
    replied
    Originally posted by 123qweasd View Post
    Correct.

    and if the current state is 0 (off) and changes to 100 (on), then it will log "internet restored"

    The original script is simply the opposite.
    Just a quick comeback... we've lost power already a few times since this... this script works perfectly! Thanks to you and Uncle Michael

    Leave a comment:


  • ksum
    replied
    Or set the virtual device up for multiple values and then set it for the attempt number if not successful as opposed to just Off. Then have an event triggered based on attempt being 5.

    Leave a comment:


  • Uncle Michael
    replied
    Originally posted by Sireone View Post
    Is it possible to add some sort of occurrence to this script so it'll trigger after 5 ping attempts?
    You could probably do that by using the device time of the virtual device. So if it's value is 0 and the device time is greater than X, then . . .

    Leave a comment:


  • Tomgru
    replied
    perfect. thanks

    Leave a comment:


  • Sireone
    replied
    Is it possible to add some sort of occurrence to this script so it'll trigger after 5 ping attempts?

    Leave a comment:


  • 123qweasd
    replied
    Correct.

    and if the current state is 0 (off) and changes to 100 (on), then it will log "internet restored"

    The original script is simply the opposite.

    Leave a comment:


  • Tomgru
    replied
    Originally posted by 123qweasd View Post
    Hi Tomgru
    simply need to save the script under a xxxxx.vb filename within the hs3/scripts directory and call the script from an event with recurring trigger.
    Also ensure you create a virtual device and change the ref number accordingly in the script (here 3889).

    Cheers
    Yann
    So if i have this working correctly with your modified script. If the ping is successful, the virtual device should show up (or remain) "ON"....value 100
    If i lose internet, when the event runs, it will change the VD to "OFF", value 0

    Do i have it?

    Leave a comment:


  • 123qweasd
    replied
    Hi Tomgru
    simply need to save the script under a xxxxx.vb filename within the hs3/scripts directory and call the script from an event with recurring trigger.
    Also ensure you create a virtual device and change the ref number accordingly in the script (here 3889).

    Cheers
    Yann

    Leave a comment:


  • Tomgru
    replied
    Sorry, as I'm still a newbie with scripting. Can you post screen shot of hiw this WORK S? Assume it's in a virtual device,.. and or updates another virtual device with status changes?

    Leave a comment:


  • 123qweasd
    replied
    using a slightly modified "internet on/off" version , thanks again for your help!

    Code:
    Public Sub Main(ByVal Parms As Object)
    
    Dim Google1 As String = "8.8.8.8"
    Dim Google2 As String = "8.8.4.4"
    Dim intR1 As Integer
    Dim intR2 As Integer
    
    intR1 = hs.Ping(Google1)
    intR2 = hs.Ping(Google2)
    
    If intR1 = 0 OR intR2 = 0 Then
    If hs.DeviceValue(3889) = 0 Then hs.WriteLogEx ("Internet", "Restored", "#008000")
    hs.SetDeviceValueByRef(3889, 100, True)
    Else
    hs.WriteLogEx ("Internet", "??", "#FF0000")
    hs.SetDeviceValueByRef(3889, 0, True)
    End If
    
    End Sub

    Leave a comment:


  • 123qweasd
    replied
    Originally posted by Uncle Michael View Post
    If the ping is successful the device is set to 0. It will be set to 100 if there is not a response to the ping. Try setting the device to 100. It should reset to 0 if the internet is up.
    Makes sense now, just overlooked the script logic.
    ill have to rename device to something like "Internet down - Alert" or just switch the values.
    Thanks for this useful script!
    Cheers

    Yann

    Leave a comment:


  • Uncle Michael
    replied
    Originally posted by 123qweasd View Post
    Uncle Michael

    The script doesn't return any errors, but if I manually reset the virtual device value to 0 and run the script, it won't update to 100...And internet is up obviously...
    If the ping is successful the device is set to 0. It will be set to 100 if there is not a response to the ping. Try setting the device to 100. It should reset to 0 if the internet is up.

    Leave a comment:


  • 123qweasd
    replied
    Uncle Michael

    The script doesn't return any errors, but if I manually reset the virtual device value to 0 and run the script, it won't update to 100...

    Code:
    Public Sub Main(ByVal Parms As Object)
    
    Dim Google1 As String = "8.8.8.8"
    Dim Google2 As String = "8.8.4.4"
    Dim intR1 As Integer
    Dim intR2 As Integer
    
    intR1 = hs.Ping(Google1)
    intR2 = hs.Ping(Google2)
    
    If intR1 = 0 OR intR2 = 0 Then
    If hs.DeviceValue(3889) = 100 Then hs.WriteLogEx ("Internet", "OK", "#008000")
    hs.SetDeviceValueByRef(3889, 0, True)
    Else
    hs.WriteLogEx ("Internet", "??", "#FF0000")
    hs.SetDeviceValueByRef(3889, 100, True)
    End If
    
    End Sub
    And internet is up obviously...

    Leave a comment:


  • Uncle Michael
    replied
    I wrote a short script to ping Google and update an HS device.
    Code:
    Public Sub Main(ByVal Parms As Object)
    
    Dim Google1 As String = "8.8.8.8"
    Dim Google2 As String = "8.8.4.4"
    Dim intR1 As Integer
    Dim intR2 As Integer
    
    intR1 = hs.Ping(Google1)
    intR2 = hs.Ping(Google2)
    
    If intR1 = 0 OR intR2 = 0 Then
    If hs.DeviceValue(1657) = 100 Then hs.WriteLogEx ("Internet", "OK", "#008000")
    hs.SetDeviceValueByRef(1657, 0, True)
    Else
    hs.WriteLogEx ("Internet", "??", "#FF0000")
    hs.SetDeviceValueByRef(1657, 100, True)
    End If
    
    End Sub

    Leave a comment:

Working...
X