Python Plugin: Wan IP Checker

Python and python framework
User avatar
ycahome
Posts: 212
Joined: Sunday 12 February 2017 11:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: Wan IP Checker

Post by ycahome » Sunday 11 March 2018 13:22

set url to "https://4.ifcfg.me/ip" no "http://4.ifcfg.me/ip"

normal http redirects to https but, I don't know if this redirection is possible via urllib request!!

Edit: Port0 is a variable that never used. you can ignore it.

Nickkkk72
Posts: 13
Joined: Tuesday 11 July 2017 11:02
Target OS: Raspberry Pi
Domoticz version: 3.8805-b
Location: France
Contact:

Re: Python Plugin: Wan IP Checker

Post by Nickkkk72 » Sunday 11 March 2018 13:51

- yes, i used htpps no http (was just a test).
- ok for port 0

you've right, i tested this url through my Windows web browser. I use Jessie through terminal (no GUI, it's Jessie light).
Maybe this URL isn't reachable from raspberry... searching a way to let me test it via terminal.
My device is up to date, and fresh installed.

i encountre many issues with urllib with another plugin (Melcloud)...

User avatar
ycahome
Posts: 212
Joined: Sunday 12 February 2017 11:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: Wan IP Checker

Post by ycahome » Sunday 11 March 2018 13:58

Nickkkk72 wrote:
Sunday 11 March 2018 13:51

Maybe this URL isn't reachable from raspberry... searching a way to let me test it via terminal.
My device is up to date, and fresh installed.

i encountre many issues with urllib with another plugin (Melcloud)...

Code: Select all

curl https://4.ifcfg.me/ip

Nickkkk72
Posts: 13
Joined: Tuesday 11 July 2017 11:02
Target OS: Raspberry Pi
Domoticz version: 3.8805-b
Location: France
Contact:

Re: Python Plugin: Wan IP Checker

Post by Nickkkk72 » Sunday 11 March 2018 14:07

i've already tested it with wget. was unreachable.
i've checked my ip config (static) and it was ok, but i found other issues on my LAN.
After check evrything... In fact, it was a Smart TV player which was nevertheless configured in DHCP which had a reserved IP ... and there was an IP conflict which made crazy my router...
I'm sorry for bothering you.
Thank you for the plugin, and thank you for your responsiveness ...

User avatar
ycahome
Posts: 212
Joined: Sunday 12 February 2017 11:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: Wan IP Checker

Post by ycahome » Sunday 11 March 2018 14:10

glad you sorted this out!!

User avatar
ycahome
Posts: 212
Joined: Sunday 12 February 2017 11:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: Wan IP Checker

Post by ycahome » Tuesday 03 April 2018 8:43

Hello,

Seems that "https://4.ifcfg.me/ip" that is used as default service on the plugin, is unavailable.
Alternatively you can use "http://whatismyip.akamai.com/".

More can be found on article bellow (nice work!):

https://unix.stackexchange.com/question ... ipt/194136

manjh
Posts: 354
Joined: Saturday 27 February 2016 13:49
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: NL
Contact:

Re: Python Plugin: Wan IP Checker

Post by manjh » Tuesday 03 April 2018 17:03

ycahome wrote:
Tuesday 03 April 2018 8:43
Hello,

Seems that "https://4.ifcfg.me/ip" that is used as default service on the plugin, is unavailable.
Alternatively you can use "http://whatismyip.akamai.com/".

More can be found on article bellow (nice work!):

https://unix.stackexchange.com/question ... ipt/194136
Excellent. That fixed it!
Hans

cmartens75
Posts: 7
Joined: Monday 23 April 2018 10:43
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands
Contact:

Re: Python Plugin: Wan IP Checker

Post by cmartens75 » Monday 23 April 2018 10:48

Hi,

I have installed the script. Is it necessary to create a virtual device in Domoticz under Hardware? Which steps are required for this? Besides that, how can you test the script? Thanks in advance for the answers.

User avatar
ycahome
Posts: 212
Joined: Sunday 12 February 2017 11:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: Wan IP Checker

Post by ycahome » Monday 23 April 2018 15:09

if you mean that you have installed the plugin then, no additional actions required (apart from the python prerequisites). Device will appear on your utility section.

cmartens75
Posts: 7
Joined: Monday 23 April 2018 10:43
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands
Contact:

Re: Python Plugin: Wan IP Checker

Post by cmartens75 » Monday 23 April 2018 19:58

I have installed the latest version of the plugin via GitHub and followed the installation instructions. After the installation I have changed the URL in the plugin.py file from "https://4.ifcfg.me/ip" to "http://whatismyip.akamai.com/". Besides that, I have changed the port 8080 to 14080 as Domoticz is running via port 14080 in my situation. I have assumed that this change is required, but I am not sure. Can you tell me? Finally, I have restarted Domoticz. I don't see any new devices in the Utility section. What can I do to check what is wrong? Thanks in advance for your reaction.

User avatar
ycahome
Posts: 212
Joined: Sunday 12 February 2017 11:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: Wan IP Checker

Post by ycahome » Tuesday 24 April 2018 19:19

enable debug mode for this plugin

cmartens75
Posts: 7
Joined: Monday 23 April 2018 10:43
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands
Contact:

Re: Python Plugin: Wan IP Checker

Post by cmartens75 » Wednesday 25 April 2018 22:39

Solved! I have used the script below. Besides that I created a virtual device (WAN IP) in Domoticz for storing the IP address: Settings – Hardware – Naam: WAN IP – Type: Dummy – Toevoegen. Finally I created a virtual sensor with WAN IP as name and Sensor Type: Text.

return {
on = {
timer = { 'every 4 hours' }
},

logging = {
level = domoticz.LOG_FORCE,
marker = '[WAN IP]'
},

execute = function(dz, devNil)

local dzb = dz.LOG_FORCE
local getIp = 'curl -s http://whatismyip.akamai.com/'
local tmpFile = '/home/pi/domoticz/scripts/wanip.txt'
local actIp = ''
local devIp = dz.devices('WAN IP')
local currIp = devIp.text

os.execute(getIp..' > '..tmpFile)
actIp = io.open(tmpFile):read()

if actIp == nil then actIp = 'Cannot retrieve WAN IP' end

if actIp ~= currIp then
msgTxt = 'WAN IP has changed: '..currIp..' ==> '..actIp
dz.log(msgTxt, dzb)
dz.notify('WAN IP', msgTxt, dz.PRIORITY_EMERGENCY)
devIp.updateText(actIp)
os.execute('rm '..tmpFile)
else
dz.log('No change in WAN IP', dzb)
end
end
}

User avatar
ycahome
Posts: 212
Joined: Sunday 12 February 2017 11:55
Target OS: Linux
Domoticz version: lat Beta
Contact:

Re: Python Plugin: Wan IP Checker

Post by ycahome » Wednesday 25 April 2018 22:55

cmartens75 wrote:
Wednesday 25 April 2018 22:39
Solved! I have used the script below. Besides that I created a virtual device (WAN IP) in Domoticz for storing the IP address: Settings – Hardware – Naam: WAN IP – Type: Dummy – Toevoegen. Finally I created a virtual sensor with WAN IP as name and Sensor Type: Text.

This is not a solution to your plugin problem. It's a totally different script that do (or don't do) the same job.

Try to not hijack threads by putting individual scripts on a plugin's thread.
If you want you can create your thread to the respective category.

Kivi
Posts: 6
Joined: Wednesday 15 April 2015 20:54
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: Wan IP Checker

Post by Kivi » Saturday 29 September 2018 13:59

I'm using https://wtfismyip.com/text and works great.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest