Jump to content

Does/Can Portal trigger program when there is no internet?


stillwater

Recommended Posts

I am wondering whether the ISY994i connected to the ISY Portal can trigger a program (or, the equivalently, set a state variable) when internet connectivity is lost -- enabling ISY to reboot a router or modem (via insteon outlet or relay) to attempt to restore internet.   

Link to comment

Yes, that's possible.

First of all, create a program that you will call via ISY Portal every 5 minutes or so:

Heartbeat timer

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
        $PI_Heartbeat_active  = 1
        Wait  6 minutes 
        $PI_Heartbeat_active  = 0
 
Else
   - No Actions - (To add one, press 'Action')

And:

Heartbeat notification

If
        $PI_Heartbeat_active is not 0
 
Then
        Send Notification to 'myself@gmail.com' content 'PI Heartbeat restarted'
 
Else
        Send Notification to 'myself@gmail.com' content 'PI Heartbeat stopped'

Then, you need to create a network resource to trigger that program via ISY Portal.

First of all, find the ID of the heartbeat program (The first one above). In the admin console, when you have your list of programs, that will be the rightmost column. It's a 4 hexadecimal digits.

To get the correct URL to call this program,  go to ISY Portal, on your ISY, use Select tools | ISY information. The "URL to ISY" is the base URL to call rest commands. It will look like this:

https://my.isy.io/isy/969f220dfc964cdb9c4cf4ef40275a580f7f8836ed3b7dc12047aa73f7e6f999

To that URL, add /rest/programs/<Program ID>/runThen

Replace <Program ID> with your program ID.

You can try this URL in a browser to make sure you are getting it right. 

Now to create the network resource, in the admin console, go to Configuration | Network resources. Click Add.

Choose https, GET, host: my.isy.io, Port: 443, Path: Everything after my.isy.io (from the above URL), encode URL: no, use SNI: No 

In the HTTP headers, click Add, choose Authorization, and enter your portal user ID and password.

Calling this network resource should trigger your heartbeat program 

Now, it's a matter of creating a program that will call this network resource every 5 minutes. If the network connectivity is lost, the heartbeat program will not be fired, and your variable will become 0, which will allow the second program to send a notification, or do whatever you want to do when there is no connectivity.

This program would work. If ISY is restarted, the program would start looping at 6AM next day.

test 

If
        Time is  6:00:00AM
 
Then
        Resource 'test'
        Wait  5 minutes 
        Run Program 'test' (Then Path)
 
Else
   - No Actions - (To add one, press 'Action')

Benoit

 

 

 

Link to comment

Thanks @bmercier

That's very helpful but it introduces a separate point of failure (the external computer that needs to talk to the ISY over the internet every 5 minutes).  

I was hoping for something built in to the ISY portal itself  that would not require active intervention from an outside computer.  

What I was thinking of was that the ISY would periodically ping or otherwise communicate with  the portal server (assuming there is such a thing)  and if it didn't get a response then it could take an action (in my case run a program that would turn power off to the router and modem and turn it back on).    This presumes that the portal server is up with high reliability.  

Of course it doesn't have to be the ISY portal that is the outside server performing this function.  For example The ISY already set up to periodically get time information from a NTP server or pool.  If there were a system variable to indicate whether this update had succeeded, that could be used as the trigger for a program  -- that would be all that I would need, thought it would be best if it could retry and only provide the "failure" signal after  a couple of retries. 

Link to comment

This opens up a lot of possibilities.  Thanks for the idea stillwater and thanks for the solution bmercier!

I have programs to notify me when the power goes out (via Elk M1) and when the power comes back on (via Elk M1 and via ISY power-up), but this will let me monitor when just the internet goes out (possible modem or router lock-up).  Awesome!

Attempting a power cycle via insteon outlet on the modem/router is another great idea on top of the monitoring.

Link to comment
1 minute ago, toflaherty said:

Benoit, the network resource performing the run then on the heartbeat timer does not stop the "wait 6 minutes" in that program, so it sets the heartbeat active variable back to 0 after the timer.

Yes it does. If the program is constantly restarted every 5 minutes, the 6 minute wait will never complete. The program does not have to be stopped. Restarting it using runThen is enough.

Link to comment
2 minutes ago, bmercier said:

Yes it does. If the program is constantly restarted every 5 minutes, the 6 minute wait will never complete. The program does not have to be stopped. Restarting it using runThen is enough.

Yes, sorry, i deleted my post but you already replied.

That was the first network resource I ever made, and something was actually wrong with it.  I don't know what, but when I tried the address manually in a browser, it reset the variable back to 1 and everything started working again.  I'll carefully check your instructions to see where I went wrong with the network resource.

Link to comment
1 minute ago, toflaherty said:

Yes, sorry, i deleted my post but you already replied.

That was the first network resource I ever made, and something was actually wrong with it.  I don't know what, but when I tried the address manually in a browser, it reset the variable back to 1 and everything started working again.  I'll carefully check your instructions to see where I went wrong with the network resource.

Not a problem. I'll delay my replies next time :-)

Benoit

Link to comment
1 minute ago, bmercier said:

Not a problem. I'll delay my replies next time :-)

Benoit

Haha, unfortunately I don't have a follow-up to what went wrong.  I opened the network resource, looked around, didn't change anything because I couldn't see anything wrong, then closed it, saved it, and everything is working perfectly now.

Link to comment

I have been trying to get this to work on my remote ISY. For some reason I can not trigger my timer program via network resources or the browser. URL looks correct. I've gone through everything several times and get the following when I test from network resources.

image.thumb.png.dbda1cfa9c8beae81adca4e89f53ca7e.png 

Link to comment
I have been trying to get this to work on my remote ISY. For some reason I can not trigger my timer program via network resources or the browser. URL looks correct. I've gone through everything several times and get the following when I test from network resources.
image.thumb.png.dbda1cfa9c8beae81adca4e89f53ca7e.png 



What do you get when trying from a browser?


Sent from my iPhone using Tapatalk
Link to comment
It just logs into the portal. No errors or messages.image.thumb.png.9ccde3d9b37dfacdc5467454bc09d7a2.png



Then there is an error in the URL. You should be getting an XML message coming from ISY, and your program should be running. You should get this working first before trying using the network resource.

Also make sure to change your portal password as you just shared it with this post.


Sent from my iPhone using Tapatalk
Link to comment

I figured it out. I must have an issue with the internet connection at the remote site. I set it up on my home ISY and it triggers the program on the remote ISY. Go figure.

Thanks again

 

Link to comment
  • 10 months later...

Hi @bmercier

Thanks for the procedure to implement heartbeat monitoring on the UDI Portal. I followed your instructions to create and call the Network Resource and it works. I was just checking my ISY error log and see strings of entries related to this monitoring. I searched the web for Module Rule 43, Error 6 but couldn't find any information. Should I be concerned about these:

Sat 2020/03/14 23:05:07    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sat 2020/03/14 23:55:10    System    -170001    [TCP-Conn] -1/-140002, Net Module Rule: 1    
Sun 2020/03/15 00:00:07    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 01:03:12    System    -5012    0    
Sun 2020/03/15 01:03:17    System    -140000    sub.isy.io    
Sun 2020/03/15 01:03:17    System    -5013    0    
Sun 2020/03/15 01:03:24    System    -140000    my.isy.io    
Sun 2020/03/15 01:03:59    System    -140000    my.isy.io    
Sun 2020/03/15 01:50:07    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 01:55:07    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 02:00:07    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 02:45:07    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 03:11:34    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 04:01:25    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 05:11:24    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 07:45:02    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 08:50:02    System    -170001    [UDSockets] Net Module Rul:43 error:6    

This is NOT a high priority as my system appears to be running normally. 

Thanks for your help.

Link to comment
9 minutes ago, gviliunas said:

Hi @bmercier

Thanks for the procedure to implement heartbeat monitoring on the UDI Portal. I followed your instructions to create and call the Network Resource and it works. I was just checking my ISY error log and see strings of entries related to this monitoring. I searched the web for Module Rule 43, Error 6 but couldn't find any information. Should I be concerned about these:

Sat 2020/03/14 23:05:07    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sat 2020/03/14 23:55:10    System    -170001    [TCP-Conn] -1/-140002, Net Module Rule: 1    
Sun 2020/03/15 00:00:07    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 01:03:12    System    -5012    0    
Sun 2020/03/15 01:03:17    System    -140000    sub.isy.io    
Sun 2020/03/15 01:03:17    System    -5013    0    
Sun 2020/03/15 01:03:24    System    -140000    my.isy.io    
Sun 2020/03/15 01:03:59    System    -140000    my.isy.io    
Sun 2020/03/15 01:50:07    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 01:55:07    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 02:00:07    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 02:45:07    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 03:11:34    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 04:01:25    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 05:11:24    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 07:45:02    System    -170001    [UDSockets] Net Module Rul:43 error:6    
Sun 2020/03/15 08:50:02    System    -170001    [UDSockets] Net Module Rul:43 error:6    

This is NOT a high priority as my system appears to be running normally. 

Thanks for your help.

I have no clue. 

@Michel Kohanim might be able to help here.

Benoit

 

 

Link to comment
  • 5 months later...
11 hours ago, maxnorth said:

Michel,

This is interesting, but perhaps I am missing something.  How does the notification program send an email if the internet is down?

It can't.  the original question was:

On 4/9/2019 at 7:15 PM, stillwater said:

I am wondering whether the ISY994i connected to the ISY Portal can trigger a program (or, the equivalently, set a state variable) when internet connectivity is lost -- enabling ISY to reboot a router or modem (via insteon outlet or relay) to attempt to restore internet.   

I'm not sure why in the second post @bmercier uses the example of sending a notification because that clearly is not possible if the internet has gone offline.

 

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...