Python Plugin: Wan IP Checker

Python and python framework

Moderator: leecollings

Post Reply
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Plugin - Wan IP Checker

Post by ycahome »

manjh wrote: Thursday 01 February 2018 12:41 Hmmm. replaced the code in the plugin.py, restarted Domoticz, and enabled the plugin.

Code: Select all

2018-02-01 12:40:01.517 Error: (WAN IP checker) 'onHeartbeat' failed 'ValueError'.
2018-02-01 12:40:01.517 Error: (WAN IP checker) ----> Line 151 in /home/pi/domoticz/plugins/WAN-IP-CHECKER/plugin.py, function onHeartbeat
2018-02-01 12:40:01.517 Error: (WAN IP checker) ----> Line 102 in /home/pi/domoticz/plugins/WAN-IP-CHECKER/plugin.py, function onHeartbeat
2018-02-01 12:40:01.517 Error: (WAN IP checker) ----> Line 153 in /usr/lib/python3.4/urllib/request.py, function urlopen
2018-02-01 12:40:01.517 Error: (WAN IP checker) ----> Line 440 in /usr/lib/python3.4/urllib/request.py, function open
2018-02-01 12:40:01.517 Error: (WAN IP checker) ----> Line 258 in /usr/lib/python3.4/urllib/request.py, function __init__
2018-02-01 12:40:01.517 Error: (WAN IP checker) ----> Line 284 in /usr/lib/python3.4/urllib/request.py, function full_url
2018-02-01 12:40:01.517 Error: (WAN IP checker) ----> Line 313 in /usr/lib/python3.4/urllib/request.py, function _parse
2018-02-01 12:40:03.075 dzVents: Warning! WAN IP has changed!
please set "Debug" to "True" and PM me the results.
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Plugin - Wan IP Checker

Post by manjh »

ycahome wrote: Thursday 01 February 2018 13:20
manjh wrote: Thursday 01 February 2018 12:41 Hmmm. replaced the code in the plugin.py, restarted Domoticz, and enabled the plugin.

Code: Select all

2018-02-01 12:40:01.517 Error: (WAN IP checker) 'onHeartbeat' failed 'ValueError'.
2018-02-01 12:40:01.517 Error: (WAN IP checker) ----> Line 151 in /home/pi/domoticz/plugins/WAN-IP-CHECKER/plugin.py, function onHeartbeat
2018-02-01 12:40:01.517 Error: (WAN IP checker) ----> Line 102 in /home/pi/domoticz/plugins/WAN-IP-CHECKER/plugin.py, function onHeartbeat
2018-02-01 12:40:01.517 Error: (WAN IP checker) ----> Line 153 in /usr/lib/python3.4/urllib/request.py, function urlopen
2018-02-01 12:40:01.517 Error: (WAN IP checker) ----> Line 440 in /usr/lib/python3.4/urllib/request.py, function open
2018-02-01 12:40:01.517 Error: (WAN IP checker) ----> Line 258 in /usr/lib/python3.4/urllib/request.py, function __init__
2018-02-01 12:40:01.517 Error: (WAN IP checker) ----> Line 284 in /usr/lib/python3.4/urllib/request.py, function full_url
2018-02-01 12:40:01.517 Error: (WAN IP checker) ----> Line 313 in /usr/lib/python3.4/urllib/request.py, function _parse
2018-02-01 12:40:03.075 dzVents: Warning! WAN IP has changed!
please set "Debug" to "True" and PM me the results.
Done
Hans
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Plugin - Wan IP Checker

Post by ycahome »

manjh wrote: Thursday 01 February 2018 13:36
you forgot the "https://" prefix on the Check My IP URL.
Seems that "except" cannot catch "ValueError"
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Plugin - Wan IP Checker

Post by manjh »

ycahome wrote: Thursday 01 February 2018 13:40
manjh wrote: Thursday 01 February 2018 13:36
you forgot the "https://" prefix on the Check My IP URL.
Seems that "except" cannot catch "ValueError"
Yes, that did it! :)

I think it would be useful to add a check on this. People are so used to typing the URL without the prefix.
For instance, when I type "hashemian.com/whoami/" in my browser address line, it will automatically add the
prefix "https://www." to create the full URL.
Alternatively, add a text on the window to make sure people type the complete, full URL...
Hans
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Plugin - Wan IP Checker

Post by manjh »

Last question on testing: in order to test the whole string of actions, I would like to see a mail coming into my mailbox from the plugin.
Is there a way to force this? Can I manually change the "kept" URL to trigger this? Where is it stored?
Hans
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Plugin - Wan IP Checker

Post by ycahome »

manjh wrote: Thursday 01 February 2018 13:55 Last question on testing: in order to test the whole string of actions, I would like to see a mail coming into my mailbox from the plugin.
Is there a way to force this? Can I manually change the "kept" URL to trigger this? Where is it stored?
You put me on a close pressing, :-)

Ok, update it once more. You are going to find some interesting features.
Enable notifications and Debug mode, put check interval at "60". Notifications are triggered on every 5 minutes (1st and 5th minute)

I hope you like it,
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Plugin - Wan IP Checker

Post by manjh »

ycahome wrote: Thursday 01 February 2018 15:40
manjh wrote: Thursday 01 February 2018 13:55 Last question on testing: in order to test the whole string of actions, I would like to see a mail coming into my mailbox from the plugin.
Is there a way to force this? Can I manually change the "kept" URL to trigger this? Where is it stored?
You put me on a close pressing, :-)
Yes, I hear that a lot. I have worked several years as professional SW tester for a worldclass IT company, so I guess it's in my blood...
Hans
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Plugin - Wan IP Checker

Post by manjh »

changed and restarted...

Code: Select all

2018-02-01 16:52:12.526 (WAN IP checker) Initialized version 1.2.1, author 'ycahome'
2018-02-01 16:52:12.581 (WAN IP checker) Debug log level set to: 'false'.
2018-02-01 16:52:16.845 (P1 meter) P1 Smart Meter (Power)
2018-02-01 16:52:18.303 (RFLink De Meern) Temp + Humidity (Alecto V4)
2018-02-01 16:52:24.864 (WAN IP checker) WAN IP Updated to:145.129.114.127
2018-02-01 16:52:24.866 (WAN IP checker) Running WAN IP Notifications
2018-02-01 16:52:24.870 Incoming connection from: ::1
2018-02-01 16:52:24.873 Error: (WAN IP checker) HTTP Request error: HTTP Error 401: Unauthorized URL: http://localhost:8080/json.htm?type=command¶m=sendnotification&subject=WAN-IP-Changed&body=145.129.114.127
Also found that after restart there were suddenly two entries in the HW overview, different IDX's.
After a bit of thought removed both and added a new line.
Last edited by manjh on Thursday 01 February 2018 16:59, edited 1 time in total.
Hans
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Plugin - Wan IP Checker

Post by ycahome »

manjh wrote: Thursday 01 February 2018 16:53 changed and restarted...

Code: Select all

2018-02-01 16:52:12.526 (WAN IP checker) Initialized version 1.2.1, author 'ycahome'
2018-02-01 16:52:12.581 (WAN IP checker) Debug log level set to: 'false'.
2018-02-01 16:52:16.845 (P1 meter) P1 Smart Meter (Power)
2018-02-01 16:52:18.303 (RFLink De Meern) Temp + Humidity (Alecto V4)
2018-02-01 16:52:24.864 (WAN IP checker) WAN IP Updated to:145.129.114.127
2018-02-01 16:52:24.866 (WAN IP checker) Running WAN IP Notifications
2018-02-01 16:52:24.870 Incoming connection from: ::1
2018-02-01 16:52:24.873 Error: (WAN IP checker) HTTP Request error: HTTP Error 401: Unauthorized URL: http://localhost:8080/json.htm?type=command¶m=sendnotification&subject=WAN-IP-Changed&body=145.129.114.127
Lets not talk about Testing and troubleshooting, will overrun this forum.

what is your Domoticz Http port? obviously not 8080
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Plugin - Wan IP Checker

Post by manjh »

ycahome wrote: Thursday 01 February 2018 16:58
manjh wrote: Thursday 01 February 2018 16:53 changed and restarted...

Code: Select all

2018-02-01 16:52:12.526 (WAN IP checker) Initialized version 1.2.1, author 'ycahome'
2018-02-01 16:52:12.581 (WAN IP checker) Debug log level set to: 'false'.
2018-02-01 16:52:16.845 (P1 meter) P1 Smart Meter (Power)
2018-02-01 16:52:18.303 (RFLink De Meern) Temp + Humidity (Alecto V4)
2018-02-01 16:52:24.864 (WAN IP checker) WAN IP Updated to:145.129.114.127
2018-02-01 16:52:24.866 (WAN IP checker) Running WAN IP Notifications
2018-02-01 16:52:24.870 Incoming connection from: ::1
2018-02-01 16:52:24.873 Error: (WAN IP checker) HTTP Request error: HTTP Error 401: Unauthorized URL: http://localhost:8080/json.htm?type=command¶m=sendnotification&subject=WAN-IP-Changed&body=145.129.114.127
It is 8080.
Lets not talk about Testing and troubleshooting, will overrun this forum.

what is your Domoticz Http port? obviously not 8080
Could it be caused by that duplicate HW line? The same plugin was defined twice somehow. I removed them and re-installed, and now it doesn't crash. But I don't see any new options, and no mail getting into my mail box...
Hans
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Plugin - Wan IP Checker

Post by ycahome »

Did you set :
- plugin "Notifications" = Notify?
- plugin "Debug" = True?
- Domoticz Email Settings?
- Waited 5 minutes?


Have you got any new errors on your log?

I think that you should leave your Testing Hat and work on your troubleshooting skills ;) :)
mailsettings.JPG
mailsettings.JPG (110.48 KiB) Viewed 2460 times
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Plugin - Wan IP Checker

Post by manjh »

ycahome wrote: Thursday 01 February 2018 17:18 Did you set :
- plugin "Notifications" = Notify? YES
- plugin "Debug" = True? YES
- Domoticz Email Settings? checked, all is correct
- Waited 5 minutes? YES


Have you got any new errors on your log? NO

I think that you should leave your Testing Hat and work on your troubleshooting skills ;) :) :-)

mailsettings.JPG
Hans
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Plugin - Wan IP Checker

Post by manjh »

got this again:

Code: Select all

2018-02-01 17:25:47.455 (WAN IP Checker) WAN IP retrieved:145.129.114.127
2018-02-01 17:25:47.455 (WAN IP Checker) Previous WAN IP:145.129.114.127
2018-02-01 17:25:47.455 Error: (WAN IP Checker) Debug is on. Trigering IP Change:
2018-02-01 17:25:47.456 (WAN IP Checker) WAN IP Updated to:145.129.114.127
2018-02-01 17:25:47.456 (WAN IP) Updating device from 1:'145.129.114.127' to have values 1:'145.129.114.127'.
2018-02-01 17:25:47.817 (WAN IP Checker) Running WAN IP Notifications
2018-02-01 17:25:47.823 Error: (WAN IP Checker) HTTP Request error: HTTP Error 401: Unauthorized URL: http://localhost:8080/json.htm?type=command¶m=sendnotification&subject=WAN-IP-Changed&body=145.129.114.127
2018-02-01 17:26:44.980 (WAN IP Checker) Calling message handler 'onHeartbeat'.
2018-02-01 17:26:44.980 (WAN IP Checker) onHeartbeat called
2018-02-01 17:26:46.427 (WAN IP Checker) IP Discovery Site's response len is:15
2018-02-01 17:26:46.427 (WAN IP Checker) WAN IP retrieved:145.129.114.127
2018-02-01 17:26:46.427 (WAN IP Checker) Previous WAN IP:145.129.114.127
2018-02-01 17:26:46.427 (WAN IP Checker) WAN IP the same. Skipping
Hans
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Plugin - Wan IP Checker

Post by manjh »

manjh wrote: Thursday 01 February 2018 17:26
ycahome wrote: Thursday 01 February 2018 17:18 I think that you should leave your Testing Hat and work on your troubleshooting skills ;) :)
mailsettings.JPG
Yeah, testers can be a real pain-in-the-youknowwhat... :D

Are you sure this is a valid URL on a Raspberry-Pi : http://localhost:8080
Hans
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Plugin - Wan IP Checker

Post by ycahome »

manjh wrote: Thursday 01 February 2018 17:34 Are you sure this is a valid URL on a Raspberry-Pi : http://localhost:8080
Is it a Raspbian jessie? or something different?

Also, you have set your Domoticz for "http"? "https"? or both?

Do you have authentication (password) set on your Domoticz?

P.S.: try to run from your PC by replacing <domoticz ip> with your server's IP:

http://<domoticz ip>:8080/json.htm?type=command&param=sendnotification&subject=WAN-IP-Changed&body=145.129.114.127
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Plugin - Wan IP Checker

Post by manjh »

ycahome wrote: Thursday 01 February 2018 18:01
manjh wrote: Thursday 01 February 2018 17:34 Are you sure this is a valid URL on a Raspberry-Pi : http://localhost:8080
Is it a Raspbian jessie? or something different?

Also, you have set your Domoticz for "http"? "https"? or both?

Do you have authentication (password) set on your Domoticz?

P.S.: try to run from your PC by replacing <domoticz ip> with your server's IP:

http://<domoticz ip>:8080/json.htm?type=command&param=sendnotification&subject=WAN-IP-Changed&body=145.129.114.127
When done from my Win10 laptop,it comes back with this:
{
status: "OK",
title: "SendNotification"
}
I use Jessie. On the settings, I have this in local networks: 10.0.0.*; 127.0.0.*; 10.8.0.*
10.0.0 is my lan IP range. 127.0.0 for local, and 10.8.0 for access via VPN.

The good news is that I now see an email in my inbox! So if we tackle the triggering, we're all done!
Hans
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Plugin - Wan IP Checker

Post by ycahome »

Do you have password protection on your domoticz?
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Plugin - Wan IP Checker

Post by ycahome »

Check a new minor version 1.2.2
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Plugin - Wan IP Checker

Post by manjh »

ycahome wrote: Thursday 01 February 2018 20:52 Do you have password protection on your domoticz?
Yes I do. But anything coming from within my network (10.0.0.*) comes in free. As wel as 127.0.0.*, and 10.0.8.*.
Hans
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Plugin - Wan IP Checker

Post by ycahome »

manjh wrote: Thursday 01 February 2018 22:26
ycahome wrote: Thursday 01 February 2018 20:52 Do you have password protection on your domoticz?
Yes I do. But anything coming from within my network (10.0.0.*) comes in free. As wel as 127.0.0.*, and 10.0.8.*.
try to add "::1", I saw that connections from localhost logged as "Incoming connection from: ::1"

Don't forget to use version 1.2.2. Contains some corrections.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest