Announcement

Collapse
No announcement yet.

How to detect internet connectivity on HS Server

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

    How to detect internet connectivity on HS Server

    Is there any way to detect if your HS Server has internet connectivity? To be clear, not local LAN connectivity, but actually out to the internet? I want to be able to use this as a trigger for an event. I'm running Ubiquiti gear, and see that PI, but not sure it does that and i don't need everything else it does.

    Thoughts?

    #2
    I ping Google periodically.
    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
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.548, NUC i3

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

    Comment


      #3
      Originally posted by Uncle Michael View Post
      I ping Google periodically.
      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
      interesting. I fear i'd have to do this a lot to make my event work. (per another thread... trying to detect when my generator is on.. power out, so is internet at my house).

      Mind if i ask how often, and what's your use case?

      Thanks!

      Comment


        #4
        I doubt there is any downside to doing it often. I would guess that Google gets pinged bazillions of times every millisecond. I do it every 15 minutes.
        Mike____________________________________________________________ __________________
        HS3 Pro Edition 3.0.0.548, NUC i3

        HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

        Comment


          #5
          Originally posted by Uncle Michael View Post
          I doubt there is any downside to doing it often. I would guess that Google gets pinged bazillions of times every millisecond. I do it every 15 minutes.
          LOL. true.

          So i'm a newbie when it comes to scripts. If i wanted to create an event that did this every 10 minutes, then if internet "does not equal" true, take action, can you help me with what that would look like. How do i get the value out of the script to act on?

          THanks!!!!!

          Comment


            #6
            Originally posted by Tomgru View Post
            Is there any way to detect if your HS Server has internet connectivity? .

            Thoughts?
            What's YOUR use case? The Internet isn't a single entity but a logical construct for an unspecific collection of things. Hard to judge connectivity to that. You can test connectivity to specific sites, or your own WAN provider's gateway for example. That just tests connectivity, however and there are other failure modes, like failure of name resolution.

            Jon00 has a Network testing script that lets you trigger events on up/down of specific tracked IP addresses.

            If you want something more sophisticated, PRTG has a free version that will let you monitor 100 sensors which include connectivity, DNS, DHCP, bandwidth, etc.

            Comment


              #7
              Originally posted by mterry63 View Post

              What's YOUR use case? The Internet isn't a single entity but a logical construct for an unspecific collection of things. Hard to judge connectivity to that. You can test connectivity to specific sites, or your own WAN provider's gateway for example. That just tests connectivity, however and there are other failure modes, like failure of name resolution.

              Jon00 has a Network testing script that lets you trigger events on up/down of specific tracked IP addresses.

              If you want something more sophisticated, PRTG has a free version that will let you monitor 100 sensors which include connectivity, DNS, DHCP, bandwidth, etc.
              My need case is very unsophisticated... i've posted about it in another thread, but wanted to parse out the ideas in case some one else was looking for a solution.

              basically, when my power goes out, my generator automatically comes on. But because my internet provider is on same power grid, i still don't have internet. This causes some of my PIs to misbehave as they ping the internet to work (e.g. ecobee). I'd like to reboot those when my generator is off and i have internet again. I'm looking at ways to monitor my generator, but i thought this might be a much easier solution.

              Comment


                #8
                In that scenario I'd use jon00's utility to monitor the site name/IP that the ecobee is connecting to. It's easy to install and configure, and creates devices you can use in events. It's in the forum here as Jon00 Network Monitoring for HS2,3, and 4, I believe.


                Sent from my Pixel 2 using Tapatalk

                Comment


                  #9
                  Originally posted by mterry63 View Post
                  In that scenario I'd use jon00's utility to monitor the site name/IP that the ecobee is connecting to. It's easy to install and configure, and creates devices you can use in events. It's in the forum here as Jon00 Network Monitoring for HS2,3, and 4, I believe.


                  Sent from my Pixel 2 using Tapatalk
                  Like that idea as well!

                  Comment


                    #10
                    Originally posted by mterry63 View Post
                    In that scenario I'd use jon00's utility to monitor the site name/IP that the ecobee is connecting to.
                    Interesting. I see warnings in my log that my Ecobee thermostats cannot connect much more frequently than actual loss of internet generally. They typically last less than an hour. I'd be concerned about nuisance notices outnumbering the real ones.

                    Mike____________________________________________________________ __________________
                    HS3 Pro Edition 3.0.0.548, NUC i3

                    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                    Comment


                      #11
                      Can't argue with that, especially if the plugin can't fail gracefully or recover gracefully when it can't contact the mothership. I have a similar issue with the Ambient Weather plugin that sets devices to zero when it can't contact the site. I'd much prefer it just left them at the last value.

                      Comment


                        #12
                        I use NR for this. Quite simple.

                        Verstuurd vanaf mijn SM-G965F met Tapatalk

                        Comment


                          #13
                          Originally posted by kriz83 View Post
                          I use NR for this. Quite simple.

                          Verstuurd vanaf mijn SM-G965F met Tapatalk
                          NR?

                          Comment


                            #14
                            NodeRed.

                            The flow pings google every minute. If it fails 5 times in a row, my modem and networking gear is power cycled. However, it will only power cycle it once/hour.
                            Attached Files

                            Comment


                              #15
                              Originally posted by kriz83 View Post
                              NodeRed.

                              The flow pings google every minute. If it fails 5 times in a row, my modem and networking gear is power cycled. However, it will only power cycle it once/hour.
                              Would you mind exporting this flow and sharing it. It is a good example of how to use Node-RED for this task.

                              Comment

                              Working...
                              X