Announcement

Collapse
No announcement yet.

How to detect internet connectivity on HS Server

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

    #16
    Originally posted by Tomgru View Post

    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.
    Do you have any circuits that are not on the generator? I have a similar use case, but use an ecolink sensor connected to a relay to report when power is out/back on. TheSmartestHouse sells these in a kit. I have a few circuits not on the generator. Monitoring internet connectivity seems like an end-run around the problem.

    I do separately monitor connectivity, and also use Ubiquiti equipment, but not for detected power outages.

    Separately - surprised the internet provider doesn't have some kind of backup, at least for a few hours. I'm stuck with Spectrum, and they seem to have about four hours of reserve power before what I presume are batteries die.

    Comment


      #17
      Originally posted by drhtmal View Post

      Would you mind exporting this flow and sharing it. It is a good example of how to use Node-RED for this task.
      You will have to tweak it a bit, since it is using the HomeAssistant nodes.

      Code:
      [{"id":"ecd2fa36.9d6a58","type":"ping","z":"6fea605b.2813d","name":"","host":"www.google.com","timer":"60","inputs":0,"x":105,"y":75,"wires":[["fdb2db27.5f7a88"]]},{"id":"fdb2db27.5f7a88","type":"switch","z":"6fea605b.2813d","name":"offline ?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"false","vt":"jsonata"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":75,"wires":[["ff09d71a.394438"],["4f8896ba.1a8288"]]},{"id":"3c704a0f.b74d46","type":"api-call-service","z":"6fea605b.2813d","name":"Modem off","server":"98e45af.82949a8","version":"1","debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.meterkast","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1070,"y":100,"wires":[["8ee5c2a6.a659d"]]},{"id":"8ee5c2a6.a659d","type":"delay","z":"6fea605b.2813d","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1220,"y":100,"wires":[["c6980ba5.a428c8","571b849d.b16c4c"]]},{"id":"c6980ba5.a428c8","type":"api-call-service","z":"6fea605b.2813d","name":"Modem on","server":"98e45af.82949a8","version":"1","debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.meterkast","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1370,"y":100,"wires":[[]]},{"id":"ae9099ba.c2db38","type":"api-call-service","z":"6fea605b.2813d","name":"log","server":"98e45af.82949a8","version":"1","debugenabled":false,"service_domain":"logbook","service":"log","entityId":"","data":"{\"name\":\"Node-RED:\",\"message\":\"!! Internet verbinding verloren !!\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":925,"y":125,"wires":[["3c704a0f.b74d46","b972c26c.f0621"]]},{"id":"571b849d.b16c4c","type":"api-call-service","z":"6fea605b.2813d","name":"Rack on","server":"98e45af.82949a8","version":"1","debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.rack","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1360,"y":40,"wires":[[]]},{"id":"1ff82e85.b4e061","type":"delay","z":"6fea605b.2813d","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"hour","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":820,"y":75,"wires":[["ae9099ba.c2db38"]]},{"id":"ff09d71a.394438","type":"counter","z":"6fea605b.2813d","name":"","init":"5","step":"1","lower":"0","upper":null,"mode":"decrement","outputs":"1","x":485,"y":75,"wires":[["79eaf240.c2f88c"]]},{"id":"4f8896ba.1a8288","type":"change","z":"6fea605b.2813d","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":125,"wires":[["ff09d71a.394438"]]},{"id":"79eaf240.c2f88c","type":"switch","z":"6fea605b.2813d","name":"counter == 0","property":"count","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":645,"y":75,"wires":[["1ff82e85.b4e061","4f8896ba.1a8288"]]},{"id":"b972c26c.f0621","type":"api-current-state","z":"6fea605b.2813d","name":"Vakantie ?","server":"98e45af.82949a8","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.vakantie_modus","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1070,"y":180,"wires":[["f65f8e16.5c1f3"],[]]},{"id":"f65f8e16.5c1f3","type":"api-call-service","z":"6fea605b.2813d","name":"Rack off","server":"98e45af.82949a8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.rack","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1240,"y":180,"wires":[[]]},{"id":"98e45af.82949a8","type":"server","z":"","name":"Home Assistant","legacy":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false}]

      Comment


        #18
        Originally posted by Tomgru View Post

        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!!!!!
        Lots of great suggestions coming here, but somewhat complicated. I probably would just keep it simple and fire off another event if the Internet was detected as being down:

        hs.TriggerEvent("Internet Down")

        Comment


          #19
          Originally posted by kriz83 View Post

          You will have to tweak it a bit, since it is using the HomeAssistant nodes.

          Code:
          [{"id":"ecd2fa36.9d6a58","type":"ping","z":"6fea605b.2813d","name":"","host":"www.google.com","timer":"60","inputs":0,"x":105,"y":75,"wires":[["fdb2db27.5f7a88"]]},{"id":"fdb2db27.5f7a88","type":"switch","z":"6fea605b.2813d","name":"offline ?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"false","vt":"jsonata"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":75,"wires":[["ff09d71a.394438"],["4f8896ba.1a8288"]]},{"id":"3c704a0f.b74d46","type":"api-call-service","z":"6fea605b.2813d","name":"Modem off","server":"98e45af.82949a8","version":"1","debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.meterkast","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1070,"y":100,"wires":[["8ee5c2a6.a659d"]]},{"id":"8ee5c2a6.a659d","type":"delay","z":"6fea605b.2813d","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1220,"y":100,"wires":[["c6980ba5.a428c8","571b849d.b16c4c"]]},{"id":"c6980ba5.a428c8","type":"api-call-service","z":"6fea605b.2813d","name":"Modem on","server":"98e45af.82949a8","version":"1","debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.meterkast","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1370,"y":100,"wires":[[]]},{"id":"ae9099ba.c2db38","type":"api-call-service","z":"6fea605b.2813d","name":"log","server":"98e45af.82949a8","version":"1","debugenabled":false,"service_domain":"logbook","service":"log","entityId":"","data":"{\"name\":\"Node-RED:\",\"message\":\"!! Internet verbinding verloren !!\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":925,"y":125,"wires":[["3c704a0f.b74d46","b972c26c.f0621"]]},{"id":"571b849d.b16c4c","type":"api-call-service","z":"6fea605b.2813d","name":"Rack on","server":"98e45af.82949a8","version":"1","debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.rack","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1360,"y":40,"wires":[[]]},{"id":"1ff82e85.b4e061","type":"delay","z":"6fea605b.2813d","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"hour","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":820,"y":75,"wires":[["ae9099ba.c2db38"]]},{"id":"ff09d71a.394438","type":"counter","z":"6fea605b.2813d","name":"","init":"5","step":"1","lower":"0","upper":null,"mode":"decrement","outputs":"1","x":485,"y":75,"wires":[["79eaf240.c2f88c"]]},{"id":"4f8896ba.1a8288","type":"change","z":"6fea605b.2813d","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":125,"wires":[["ff09d71a.394438"]]},{"id":"79eaf240.c2f88c","type":"switch","z":"6fea605b.2813d","name":"counter == 0","property":"count","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":645,"y":75,"wires":[["1ff82e85.b4e061","4f8896ba.1a8288"]]},{"id":"b972c26c.f0621","type":"api-current-state","z":"6fea605b.2813d","name":"Vakantie ?","server":"98e45af.82949a8","version":1,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.vakantie_modus","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1070,"y":180,"wires":[["f65f8e16.5c1f3"],[]]},{"id":"f65f8e16.5c1f3","type":"api-call-service","z":"6fea605b.2813d","name":"Rack off","server":"98e45af.82949a8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.rack","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1240,"y":180,"wires":[[]]},{"id":"98e45af.82949a8","type":"server","z":"","name":"Home Assistant","legacy":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false}]
          which contrib are you using for the Google and Counter Node?

          ---
          John

          Comment

          Working...
          X