Python Plugin: Wan IP Checker

Python and python framework

Moderator: leecollings

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 22:37
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.
I just tried to remove the access control (removed userid/pw), and ran the debug cycle again. Now the mail comes in without problems, so I can confirm that this was the root cause.

For testing sake I have reinstated the access control but now added "::1", as you suggested. I will know in five minutes...
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 »

Another usability suggestion: expand the text in the warning mail to be more descriptive.
For example:

Code: Select all

WAN IP address has changed.
Old IP : 145.129.114.127
New IP: 145.129.114.125
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:47 Another usability suggestion: expand the text in the warning mail to be more descriptive.
For example:

Code: Select all

WAN IP address has changed.
Old IP : 145.129.114.127
New IP: 145.129.114.125
:lol: You are totally right but, there are some limitations on the API.
Seems that cannot work with spaces.

I will keep trying
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 »

No luck.

I still get this:

Code: Select all

2018-02-01 22:50:22.433 (WAN IP Checker) IP Discovery Site's response len is:15
2018-02-01 22:50:22.433 (WAN IP Checker) WAN IP retrieved:145.129.114.127
2018-02-01 22:50:22.433 (WAN IP Checker) Previous WAN IP:145.129.114.127
2018-02-01 22:50:22.433 Error: (WAN IP Checker) Debug is on. Trigering IP Change:
2018-02-01 22:50:22.433 (WAN IP Checker) WAN IP Updated to:145.129.114.127
2018-02-01 22:50:22.433 (WAN IP) Updating device from 1:'145.129.114.127' to have values 1:'145.129.114.127'.
2018-02-01 22:50:22.795 (WAN IP Checker) Running WAN IP Notifications
2018-02-01 22:50:22.795 (WAN IP Checker) WAN IP retrieved:145.129.114.127
2018-02-01 22:50:22.795 (WAN IP Checker) ConstructedURL ServerURL is:http://localhost:8080/json.htm?param=sendnotification&type=command
2018-02-01 22:50:22.795 (WAN IP Checker) ConstructedURL is:http://localhost:8080/json.htm?param=sendnotification&type=command&subject=WAN-IP-Changed&body=145.129.114.127
2018-02-01 22:50:22.801 Error: (WAN IP Checker) HTTP Request error: HTTP Error 401: Unauthorized URL: http://localhost:8080/json.htm?param=sendnotification&type=command&subject=WAN-IP-Changed&body=145.129.114.127
The values in the local networks are:

Code: Select all

10.0.0.*; 127.0.0.*; 10.8.0.*;::0
For my own installation, I am going to remove userid/pw protection, since the only outside access to my net is through a VPN server anyway. Extra userid/PW protection is not needed anymore.
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 »

ycahome wrote: Thursday 01 February 2018 22:50
manjh wrote: Thursday 01 February 2018 22:47 Another usability suggestion: expand the text in the warning mail to be more descriptive.
For example:

Code: Select all

WAN IP address has changed.
Old IP : 145.129.114.127
New IP: 145.129.114.125
:lol: You are totally right but, there are some limitations on the API.
Seems that cannot work with spaces.

I will keep trying
OK. Can you store in a variable and hand that to the API?
Alternatively, use underscores instead of spaces (brrrr :shock: ).
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 22:53 No luck.

I still get this:

Code: Select all

2018-02-01 22:50:22.433 (WAN IP Checker) IP Discovery Site's response len is:15
2018-02-01 22:50:22.433 (WAN IP Checker) WAN IP retrieved:145.129.114.127
2018-02-01 22:50:22.433 (WAN IP Checker) Previous WAN IP:145.129.114.127
2018-02-01 22:50:22.433 Error: (WAN IP Checker) Debug is on. Trigering IP Change:
2018-02-01 22:50:22.433 (WAN IP Checker) WAN IP Updated to:145.129.114.127
2018-02-01 22:50:22.433 (WAN IP) Updating device from 1:'145.129.114.127' to have values 1:'145.129.114.127'.
2018-02-01 22:50:22.795 (WAN IP Checker) Running WAN IP Notifications
2018-02-01 22:50:22.795 (WAN IP Checker) WAN IP retrieved:145.129.114.127
2018-02-01 22:50:22.795 (WAN IP Checker) ConstructedURL ServerURL is:http://localhost:8080/json.htm?param=sendnotification&type=command
2018-02-01 22:50:22.795 (WAN IP Checker) ConstructedURL is:http://localhost:8080/json.htm?param=sendnotification&type=command&subject=WAN-IP-Changed&body=145.129.114.127
2018-02-01 22:50:22.801 Error: (WAN IP Checker) HTTP Request error: HTTP Error 401: Unauthorized URL: http://localhost:8080/json.htm?param=sendnotification&type=command&subject=WAN-IP-Changed&body=145.129.114.127
The values in the local networks are:

Code: Select all

10.0.0.*; 127.0.0.*; 10.8.0.*;::0
For my own installation, I am going to remove userid/pw protection, since the only outside access to my net is through a VPN server anyway. Extra userid/PW protection is not needed anymore.
OK, removed the userid/pw again, and it now works like a charm.
I'm happy, but if you want to solve the access topic: let me know if I can do more testing.
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 »

What I wanted to add to this discussion: sorry if I seemed to be a nuisance, but that is the usual tension between developer and tester.
In the end it is the quality of the plugin that counts, I think that's worth it. Don't you? :)
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 »

Suggestion: in stead of "http://localhost:8080" would it be possible to try "http://127.0.0.1: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 »

If I try to integrate authentication we should cover multiple cases and am afraid that is too much work for nothing.
I think we should wait for a native plugin notification option.

For the authentication, you can go and modify line 133 of the plugin in order to test with authentication.

Change:

Code: Select all

ServerURL = "http://localhost:8080/json.htm?param=sendnotification&type=command"


to:

Code: Select all

ServerURL = "http://username:password@localhost:8080/json.htm?param=sendnotification&type=command"

As for the localhost, will be changed to "127.0.0.1" on the next release.
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: Friday 02 February 2018 9:17 If I try to integrate authentication we should cover multiple cases and am afraid that is too much work for nothing.
I think we should wait for a native plugin notification option.

For the authentication, you can go and modify line 133 of the plugin in order to test with authentication.

Change:

Code: Select all

ServerURL = "http://localhost:8080/json.htm?param=sendnotification&type=command"


to:

Code: Select all

ServerURL = "http://username:password@localhost:8080/json.htm?param=sendnotification&type=command"

As for the localhost, will be changed to "127.0.0.1" on the next release.
I am not suggestion to incorporate userid/pw authentication into the plugin. All users would have to modify the code, and that is not a good idea.
Changing the "localhost" into "127.0.0.1" would be better, since it would then fall into the "local networks" exception. Specifying that mask in the "local networks" field in the settings tab means that any connection coming in from that subnet address mask, is excempt from userid/pw checking.
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 »

I changed "localhost" into "127.0.0.1", activated the userid/pw authentication and ran a test:

Code: Select all

2018-02-02 09:35:41.818 Error: (WAN IP Checker) Debug is on. Trigering IP Change:
2018-02-02 09:35:41.818 (WAN IP Checker) WAN IP Updated to:145.129.114.127
2018-02-02 09:35:42.465 (WAN IP Checker) Running WAN IP Notifications
2018-02-02 09:35:42.465 (WAN IP Checker) WAN IP retrieved:145.129.114.127
2018-02-02 09:35:42.466 (WAN IP Checker) ConstructedURL ServerURL is:http://127.0.0.1:8080/json.htm?param=sendnotification&type=command
2018-02-02 09:35:42.466 (WAN IP Checker) ConstructedURL is:http://127.0.0.1:8080/json.htm?param=sendnotification&type=command&subject=WAN-IP-Changed&body=145.129.114.127
The warning mail was sent successfully! So I would suggest this change in the next version would solve the triggering problem. Also, add a line covering this in the instructions: "when userid/pw checking is active, make sure to add 127.0.0.* to the Local Networks field" and the Settings tab of Domoticz.
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: Friday 02 February 2018 9:39 I changed "localhost" into "127.0.0.1", activated the userid/pw authentication and ran a test:

The warning mail was sent successfully! So I would suggest this change in the next version would solve the triggering problem. Also, add a line covering this in the instructions: "when userid/pw checking is active, make sure to add 127.0.0.* to the Local Networks field" and the Settings tab of Domoticz.
I ve changed the version and added the "disclaimer" to the first post.

Thank you for your help
User avatar
lmet
Posts: 23
Joined: Wednesday 19 July 2017 22:35
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.9700
Location: France
Contact:

Re: Python Plugin: Wan IP Checker

Post by lmet »

Hi,
I have installed your plugin and I have a problem. I receive notifications every two minutes while my WAN-IP address has not changed.
img_003.jpg
img_003.jpg (87.17 KiB) Viewed 2926 times
My wife receives SMS with the same message also with the same frequency.
I disabled the plufin while waiting for a response.
thank you in advance
I forgot to tell that I have nothing on Utility tab.
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: Wan IP Checker

Post by ycahome »

Plugin posts 3 notifications/minute on debug mode.

You can either disable "debug" mode or "notifications"
User avatar
lmet
Posts: 23
Joined: Wednesday 19 July 2017 22:35
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.9700
Location: France
Contact:

Re: Python Plugin: Wan IP Checker

Post by lmet »

Thank's a lot. Now waiting my IP to change ;)
hamster
Posts: 42
Joined: Friday 28 April 2017 19:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: USA
Contact:

Re: Python Plugin: Wan IP Checker

Post by hamster »

hey @ycahome, posted same question in thread of another plugin I use and figured I'd ask here too:
Do you have any plans to create a plugin version to work with beta versions? The way the beta handles plugins will eventually be the stable way, so was hoping you might be willing to have two versions until the merge :)
User avatar
ycahome
Posts: 248
Joined: Sunday 12 February 2017 10:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: Wan IP Checker

Post by ycahome »

hamster wrote: Friday 09 February 2018 3:20 hey @ycahome, posted same question in thread of another plugin I use and figured I'd ask here too:
Do you have any plans to create a plugin version to work with beta versions? The way the beta handles plugins will eventually be the stable way, so was hoping you might be willing to have two versions until the merge :)

Hello @hamster.

what am reading on the article you mention is that a specific breaking change happened on plugin framework. This change is related to HTTP support of this framework.
I don't use this functionality yet on my plugins via this framework. Am using urllib instead.

Apart from the above, i already tested my plugins to the latest Beta and seem to work fine.
You are facing problems?or your question was informational?
hamster
Posts: 42
Joined: Friday 28 April 2017 19:11
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: USA
Contact:

Re: Python Plugin: Wan IP Checker

Post by hamster »

Oh, I just assumed that may have been the issue because I recently went from stable to the latest beta and now none of my 3rd party plugins appear in the hardware list anymore. so, trying to figure out whats wrong.

edit: DONKEY BALLS. so, apparently the "enabled" slider for lua/events/scripts doesnt show properly in Chrome, so the thing was disabled this whole time. finally ran across another forum post that mentioned it and tried IE and could see it... geez. sorry for false report.
Last edited by hamster on Sunday 11 February 2018 18:37, edited 1 time in total.
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: Wan IP Checker

Post by manjh »

remark for the instructions on the plugin: the directory where to install is "plugins", not "plugin". Nitpicking.... :oops:
Hans
manjh
Posts: 708
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Python Plugin: Wan IP Checker

Post by manjh »

I'm confused. I have this plugin running on my "production" Domoticz server with no problems.
But now I am setting up a second R-Pi as testbed, and somehow can't get the WAN IP checker installed.
Created the WAN-IP-CHECKER directory with the plugin.py file in it.
Then restarted Domoticz service, but the hardware dropdown does not show the plugin.
I double checked and found nothing wrong. Also tried a full reboot, no luck.

Any idea what might be causing this? I'm sure it must be something I forgot, but what? :o :shock:
Hans
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests