Python Plugin: Wan IP Checker

Python and python framework

Moderator: leecollings

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 »

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: 8
Joined: Tuesday 11 July 2017 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8805-b
Location: France
Contact:

Re: Python Plugin: Wan IP Checker

Post by Nickkkk72 »

- 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: 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 »

Nickkkk72 wrote: Sunday 11 March 2018 12: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: 8
Joined: Tuesday 11 July 2017 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8805-b
Location: France
Contact:

Re: Python Plugin: Wan IP Checker

Post by Nickkkk72 »

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: 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 »

glad you sorted this out!!
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 »

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: 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 »

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: 15
Joined: Monday 23 April 2018 10:43
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Netherlands
Contact:

Re: Python Plugin: Wan IP Checker

Post by cmartens75 »

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: 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 »

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: 15
Joined: Monday 23 April 2018 10:43
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Netherlands
Contact:

Re: Python Plugin: Wan IP Checker

Post by cmartens75 »

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: 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 »

enable debug mode for this plugin
cmartens75
Posts: 15
Joined: Monday 23 April 2018 10:43
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Netherlands
Contact:

Re: Python Plugin: Wan IP Checker

Post by cmartens75 »

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: 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 »

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 »

I'm using https://wtfismyip.com/text and works great.
BarryT
Posts: 358
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Python Plugin: Wan IP Checker

Post by BarryT »

maybe some weird question, but is there a wizkid somewhere around here that could make a dyndns out from this script that should do an dynsdns update when the ip has changed? :D
i have a vps with a subdomain linked to my private ip, but when my provider changes my wan ip, i cannot connect it ofcourse.
at this moment i use the dyndns from my usg gateway that does its job, but i want to use my own (sub)domain..
Raspberry / ESP Boards / Relais / Milight / Hue / OTGW / P1 / Xiaomi / RFXCom / RFLink / ZWave / Conbee II / Z2M / MQTT / A lot of scripts and many more..
Software: Linux, Android and Windows
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 »

Dyndns providers (subscripton based) have scripts to update dynamic IPs. You can try to trigger one of those scripts from domoticz!
BarryT
Posts: 358
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Python Plugin: Wan IP Checker

Post by BarryT »

ycahome wrote: Monday 17 February 2020 19:58 Dyndns providers (subscripton based) have scripts to update dynamic IPs. You can try to trigger one of those scripts from domoticz!
Yeah, i know :)
but i do not want to use others, i just want to use my own vps and (subdomain) dns and be my own dyndns host.. ;)
Raspberry / ESP Boards / Relais / Milight / Hue / OTGW / P1 / Xiaomi / RFXCom / RFLink / ZWave / Conbee II / Z2M / MQTT / A lot of scripts and many more..
Software: Linux, Android and Windows
Dave21w
Posts: 361
Joined: Sunday 29 November 2015 21:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: UK
Contact:

Re: Python Plugin: Wan IP Checker

Post by Dave21w »

I hate to sound really stupid but here goes, I installed the plugin and indeed it works flawlessly, I have "Prowl" setup for my push notifications on other things so would like to use this to send me my IP info, where is the General txt value stored so I can do something with it ?
I have no issue with hardware construction and problem solving and software setup I can following instructions but scripting wise at the moment I have to use blockly cause i just can't get my head around anything else and it's not for the lack of trying.

TIA
Dave
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 »

Dave21w wrote: Wednesday 01 April 2020 10:09 I hate to sound really stupid but here goes, I installed the plugin and indeed it works flawlessly, I have "Prowl" setup for my push notifications on other things so would like to use this to send me my IP info, where is the General txt value stored so I can do something with it ?
I have no issue with hardware construction and problem solving and software setup I can following instructions but scripting wise at the moment I have to use blockly cause i just can't get my head around anything else and it's not for the lack of trying.

TIA
Dave
Hi Dave.

did you tried blockly Utility device actual value?
iTDB
Posts: 29
Joined: Friday 29 November 2019 18:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Gent
Contact:

Re: Python Plugin: Wan IP Checker

Post by iTDB »

It looks like you need to set the Timer to 60 sec, otherwise you will get next error every minute
Error: IP Checker hardware (Idx) thread seems to have ended unexpectedly
Is there a way to set that to 1 or 2 hours without this error.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest