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:

Python Plugin: Wan IP Checker

Post by ycahome »

Hi there.

I have managed to port emme's script bellow

viewtopic.php?t=14489

to a domoticz python plugin.
Plugin updates a "General,Text" Value with your Wan IP Address. This value can be used later on in order to update any scripts or notify you upon IP change.

I hope you like it.

Find newest version GitHub:

https://github.com/ycahome/WAN-IP-CHECKER.git




Installation instructions:
- Make sure you have Python3 installed!

Code: Select all

sudo apt-get install python3
sudo apt-get install python3-dev


Installation from GitHub:

Code: Select all

cd plugins
mkdir WAN-IP-CHECKER
sudo apt-get update
sudo apt-get install git
git clone https://github.com/ycahome/WAN-IP-CHECKER.git WAN-IP-CHECKER
cd WAN-IP-CHECKER
sudo chmod +x plugin.py
sudo /etc/init.d/domoticz.sh restart

Old Way Installation:

- Create Plugin Folder "WAN-IP-CHECKER" under "domoticz/plugins" folder
- Save this script as "plugin.py" on "WAN-IP-CHECKER" folder
- Restart domoticz service.
- Add a new entry of this Hardware on your domoticz installation (Setup/Hardware/select and add "Wan Ip Checker")


- NOTE:When userid/pw checking is active, make sure to add 127.0.0.* to the Local Networks field on the Settings of your Domoticz. ( many thanks to manjh for his help)

What am going to see?:
- Plugin will auto-add one Text Counter on your "Utility" Section named "<Your Hardware Name>- WAN IP 1".

F.A.Q
1. if I enable notification, will it send an e-mail? To which mail address?
- If you enable notifications, Domoticz notification settings will be used

2. what does the field "Check My IP URL" mean?
- is the URL that returns your WAN IP

3. Does the plugin send one single notification, or repeating?
- Single notification (one for each notification option set on settings) for every WAN IP change.

4. "Check My IP URL" .What is it used for? Compare to the outside IP address? Or should I fill in a site like WhoAmI?
- You can use the default one or another. Its up to you.
Last edited by ycahome on Sunday 11 March 2018 12:59, edited 27 times in total.
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Plugin - Wan IP Checker

Post by emme »

:shock: uh... my first remix.... :lol: :lol: :lol: :lol: :lol:

quite honored!.. Thank you!!! :D

I'll test it this evening as soon as I get back home....
The most dangerous phrase in any language is:
"We always done this way"
JimmyH1969
Posts: 153
Joined: Tuesday 28 June 2016 16:38
Target OS: Windows
Domoticz version: Beta
Location: Amersfoort NL
Contact:

Re: Plugin - Wan IP Checker

Post by JimmyH1969 »

Hi, Nice.... do you need to create a variable? I added it to the plugin folder but can't see it anywhere
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 everything goes as designed ;) , it auto-create a Text Counter on "Utility" Section named "<Your Hardware Name>- WAN IP 1".
Did you added an entry of this specific hardware after Domoticz service restart? (check Installation Instructions on my first post)
JimmyH1969
Posts: 153
Joined: Tuesday 28 June 2016 16:38
Target OS: Windows
Domoticz version: Beta
Location: Amersfoort NL
Contact:

Re: Plugin - Wan IP Checker

Post by JimmyH1969 »

Yes, i got it, but from that moment my Domoticz became unresponsive and i could no longer connect to Domoticz. I had to stop the service, delete the plugin.py and start the service again to get acess to domoticz again.... :shock:

btw this is on Windows :roll:
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 »

Although this is built on Linux, I don't think that there is anything bound to Linux architecture. Its a simple python script.
Do you have any logs?

Unfortunately I don't have a Windows based domoticz to test it...
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Plugin - Wan IP Checker

Post by emme »

Simply GREAT!!!!
it works perfectly!!!!

Just a bit more clarification for the install:
you have to be root (not pi) to enter the plugins directory... so you have to issue a
sudo su
before everything else :P
The most dangerous phrase in any language is:
"We always done this way"
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Plugin - Wan IP Checker

Post by BarryT »

Nice idea, but i get a lot of errors...

Code: Select all

2017-02-23 20:46:13.797 (WAN IP) Initialized version 1.0.0, author 'ycahome'
2017-02-23 20:46:13.804 Error: (WAN IP) 'onStart' failed 'URLError'.
2017-02-23 20:46:13.804 Error: (WAN IP) ----> Line 94 in /home/pi/domoticz/plugins/wan-ip-checker/plugin.py, function onStart
2017-02-23 20:46:13.804 Error: (WAN IP) ----> Line 49 in /home/pi/domoticz/plugins/wan-ip-checker/plugin.py, function onStart
2017-02-23 20:46:13.804 Error: (WAN IP) ----> Line 162 in /usr/local/lib/python3.5/urllib/request.py, function urlopen
2017-02-23 20:46:13.804 Error: (WAN IP) ----> Line 465 in /usr/local/lib/python3.5/urllib/request.py, function open
2017-02-23 20:46:13.804 Error: (WAN IP) ----> Line 488 in /usr/local/lib/python3.5/urllib/request.py, function _open
2017-02-23 20:46:13.804 Error: (WAN IP) ----> Line 443 in /usr/local/lib/python3.5/urllib/request.py, function _call_chain
2017-02-23 20:46:13.804 Error: (WAN IP) ----> Line 1310 in /usr/local/lib/python3.5/urllib/request.py, function unknown_open
2017-02-23 20:46:23.322 Error: (WAN IP) 'onHeartbeat' failed 'URLError'.
2017-02-23 20:46:23.322 Error: (WAN IP) ----> Line 102 in /home/pi/domoticz/plugins/wan-ip-checker/plugin.py, function onHeartbeat
2017-02-23 20:46:23.322 Error: (WAN IP) ----> Line 73 in /home/pi/domoticz/plugins/wan-ip-checker/plugin.py, function onHeartbeat
2017-02-23 20:46:23.323 Error: (WAN IP) ----> Line 162 in /usr/local/lib/python3.5/urllib/request.py, function urlopen
2017-02-23 20:46:23.323 Error: (WAN IP) ----> Line 465 in /usr/local/lib/python3.5/urllib/request.py, function open
2017-02-23 20:46:23.323 Error: (WAN IP) ----> Line 488 in /usr/local/lib/python3.5/urllib/request.py, function _open
2017-02-23 20:46:23.323 Error: (WAN IP) ----> Line 443 in /usr/local/lib/python3.5/urllib/request.py, function _call_chain
2017-02-23 20:46:23.323 Error: (WAN IP) ----> Line 1310 in /usr/local/lib/python3.5/urllib/request.py, function unknown_open
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 »

I can't tell for sure....
Am suspecting that you should rename your folder to WAN-IP-CHECKER as folders are case sensitive on Linux OS.

Can you try it?
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Plugin - Wan IP Checker

Post by BarryT »

ycahome wrote:I can't tell for sure....
Am suspecting that you should rename your folder to WAN-IP-CHECKER as folders are case sensitive on Linux OS.

Can you try it?
Hold on a sec
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Plugin - Wan IP Checker

Post by BarryT »

Code: Select all

2017-02-23 20:55:02.221 (IPChecker) Exiting work loop...
2017-02-23 20:55:02.264 (IPChecker) Stopped.
2017-02-23 20:55:02.388 Error: (WAN-IP-CHECKER) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/wan-ip-checker/:/usr/local/lib/python35.zip:/usr/local/lib/python3.5/:/usr/local/lib/python3.5/plat-linux:/usr/local/lib/python3.5/lib-dynload'.
2017-02-23 20:55:02.388 Error: (IPChecker) Module Import failed, exception: 'ImportError'
2017-02-23 20:55:02.388 Error: (IPChecker) Module Import failed: ' Name: plugin'
Rebooting now...
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Plugin - Wan IP Checker

Post by BarryT »

Code: Select all

2017-02-23 20:56:51.276 Error: (IPChecker) 'onHeartbeat' failed 'URLError'.
2017-02-23 20:56:51.276 Error: (IPChecker) ----> Line 101 in /home/pi/domoticz/plugins/WAN-IP-CHECKER/plugin.py, function onHeartbeat
2017-02-23 20:56:51.276 Error: (IPChecker) ----> Line 72 in /home/pi/domoticz/plugins/WAN-IP-CHECKER/plugin.py, function onHeartbeat
2017-02-23 20:56:51.276 Error: (IPChecker) ----> Line 162 in /usr/local/lib/python3.5/urllib/request.py, function urlopen
2017-02-23 20:56:51.276 Error: (IPChecker) ----> Line 465 in /usr/local/lib/python3.5/urllib/request.py, function open
2017-02-23 20:56:51.276 Error: (IPChecker) ----> Line 488 in /usr/local/lib/python3.5/urllib/request.py, function _open
2017-02-23 20:56:51.276 Error: (IPChecker) ----> Line 443 in /usr/local/lib/python3.5/urllib/request.py, function _call_chain
2017-02-23 20:56:51.276 Error: (IPChecker) ----> Line 1310 in /usr/local/lib/python3.5/urllib/request.py, function unknown_open
2017-02-23 20:56:54.957 OpenZWave: Received timeout notification from HomeID: 25487523, NodeID: 9 (0x09)
2017-02-23 20:56:54.959 OpenZWave: All Nodes queried
2017-02-23 20:57:01.301 Error: (IPChecker) 'onHeartbeat' failed 'URLError'.
2017-02-23 20:57:01.302 Error: (IPChecker) ----> Line 101 in /home/pi/domoticz/plugins/WAN-IP-CHECKER/plugin.py, function onHeartbeat
2017-02-23 20:57:01.302 Error: (IPChecker) ----> Line 72 in /home/pi/domoticz/plugins/WAN-IP-CHECKER/plugin.py, function onHeartbeat
2017-02-23 20:57:01.302 Error: (IPChecker) ----> Line 162 in /usr/local/lib/python3.5/urllib/request.py, function urlopen
2017-02-23 20:57:01.302 Error: (IPChecker) ----> Line 465 in /usr/local/lib/python3.5/urllib/request.py, function open
2017-02-23 20:57:01.302 Error: (IPChecker) ----> Line 488 in /usr/local/lib/python3.5/urllib/request.py, function _open
2017-02-23 20:57:01.302 Error: (IPChecker) ----> Line 443 in /usr/local/lib/python3.5/urllib/request.py, function _call_chain
2017-02-23 20:57:01.302 Error: (IPChecker) ----> Line 1310 in /usr/local/lib/python3.5/urllib/request.py, function unknown_open
2017-02-23 20:57:11.272 Error: (IPChecker) 'onHeartbeat' failed 'URLError'.
2017-02-23 20:57:11.272 Error: (IPChecker) ----> Line 101 in /home/pi/domoticz/plugins/WAN-IP-CHECKER/plugin.py, function onHeartbeat
2017-02-23 20:57:11.272 Error: (IPChecker) ----> Line 72 in /home/pi/domoticz/plugins/WAN-IP-CHECKER/plugin.py, function onHeartbeat
2017-02-23 20:57:11.272 Error: (IPChecker) ----> Line 162 in /usr/local/lib/python3.5/urllib/request.py, function urlopen
2017-02-23 20:57:11.272 Error: (IPChecker) ----> Line 465 in /usr/local/lib/python3.5/urllib/request.py, function open
2017-02-23 20:57:11.272 Error: (IPChecker) ----> Line 488 in /usr/local/lib/python3.5/urllib/request.py, function _open
2017-02-23 20:57:11.272 Error: (IPChecker) ----> Line 443 in /usr/local/lib/python3.5/urllib/request.py, function _call_chain
2017-02-23 20:57:11.272 Error: (IPChecker) ----> Line 1310 in /usr/local/lib/python3.5/urllib/request.py, function unknown_open
Still the same
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 »

Very strange, This is a raspbian?
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Plugin - Wan IP Checker

Post by BarryT »

ycahome wrote:Very strange, This is a raspbian?
Yes, it is..

2017-02-23 21:03:08.187 Domoticz V3.6775 (c)2012-2017 GizMoCuz
2017-02-23 21:03:08.188 Build Hash: 050cd55, Date: 2017-02-23 12:25:52
2017-02-23 21:03:08.188 Startup Path: /home/pi/domoticz/
2017-02-23 21:03:08.516 EventSystem: reset all events...
2017-02-23 21:03:08.956 PluginSystem: Started, Python version '3.5.0'.

Raspberry 3B with an older sd-card image of domoticz, updated to latest version
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Plugin - Wan IP Checker

Post by BarryT »

I think it has something to do with the Python, since i had to build it from source after getting errors about Python some weeks ago?
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 »

let me check on Rpi2 with latest beta
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 »

BarryT wrote:I think it has something to do with the Python, since i had to build it from source after getting errors about Python some weeks ago?
Do you have "python3-dev" installed?
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Plugin - Wan IP Checker

Post by BarryT »

ycahome wrote:
BarryT wrote:I think it has something to do with the Python, since i had to build it from source after getting errors about Python some weeks ago?
Do you have "python3-dev" installed?
Good question, hold on..

Otherwise, i think i'm going to re-install the rpi because there are just to many (old) files not in use anymore...

** weird, it seems Python 2.7.9 is my main version?
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 »

Works Perfectly on my RPi-2B with Latest beta and Raspbian.

You have probably a lack of Python.....
JimmyH1969
Posts: 153
Joined: Tuesday 28 June 2016 16:38
Target OS: Windows
Domoticz version: Beta
Location: Amersfoort NL
Contact:

Re: Plugin - Wan IP Checker

Post by JimmyH1969 »

Not working on Windows. Domoticz restarts every 10 seconds. Nothing in log, but thats hard to see if the system is no longer responding.
:(
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests