Python Plugin: Wan IP Checker

Python and python framework
poudenes
Posts: 486
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Plugin - Wan IP Checker

Post by poudenes » Saturday 02 September 2017 18:40

when this error pop up it also let crash other python scripts. Need to restart Domoticz to let it run ok again
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

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

Re: Plugin - Wan IP Checker

Post by ycahome » Monday 04 September 2017 9:36

poudenes wrote:
Wednesday 30 August 2017 9:31
Works GREAT !!!!!

Only thing: You can not use it on a Slave Domoticz and read the info on the Master Domoticz. The Device is not shown in list of "not used"devices on the Master Domoticz.

Maybe thats it thing to look at. Rest briljant plugin. Now i can check if my VPN is on !!
This depends on which type of devices/switches are allowed to be remotely transferred from Domoticz. This is not something that can be defined from plugin itself.

br,

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

Re: Plugin - Wan IP Checker

Post by ycahome » Monday 04 September 2017 10:39

#1st Post Updated with the new version.
-Improve: Timeout added to prevent stale url requests.

User avatar
EdwinK
Posts: 1201
Joined: Sunday 22 January 2017 22:46
Target OS: Raspberry Pi
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Plugin - Wan IP Checker

Post by EdwinK » Friday 15 September 2017 22:17

Used to work earlier today (no error seen), but by change I looked at the error-log tonight and noticed this

Code: Select all

2017-09-15 22:11:30.547 Error: IP Check hardware (38) thread seems to have ended unexpectedly
Running latest BETA on a Pi-3 | Toon Thermostat | RFxcom | Dashticz V2 |

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

Re: Plugin - Wan IP Checker

Post by ycahome » Sunday 17 September 2017 10:15

EdwinK wrote:
Friday 15 September 2017 22:17
Used to work earlier today (no error seen), but by change I looked at the error-log tonight and noticed this

Code: Select all

2017-09-15 22:11:30.547 Error: IP Check hardware (38) thread seems to have ended unexpectedly
Strage, did you change to new version (1.1.0)? or you still have the previous one?
Can you give more details?

User avatar
EdwinK
Posts: 1201
Joined: Sunday 22 January 2017 22:46
Target OS: Raspberry Pi
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Plugin - Wan IP Checker

Post by EdwinK » Sunday 17 September 2017 12:30

Used the latest version, running on Synology.
Running latest BETA on a Pi-3 | Toon Thermostat | RFxcom | Dashticz V2 |

User avatar
Dnpwwo
Posts: 720
Joined: Sunday 23 March 2014 10:00
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Plugin - Wan IP Checker

Post by Dnpwwo » Sunday 17 September 2017 13:47

@EdwinK,

You will see this in the log if the plugin Heartbeat is ever greater than (or equal to) 30 seconds because Domotoicz doesn't like it.

The plugin will work just fine, that is just a warning.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw

User avatar
EdwinK
Posts: 1201
Joined: Sunday 22 January 2017 22:46
Target OS: Raspberry Pi
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Plugin - Wan IP Checker

Post by EdwinK » Sunday 17 September 2017 18:22

Thanks. Will ignore it then.
Running latest BETA on a Pi-3 | Toon Thermostat | RFxcom | Dashticz V2 |

User avatar
Teknor
Posts: 34
Joined: Monday 08 February 2016 14:26
Target OS: Raspberry Pi
Domoticz version: 3.48
Location: Norway
Contact:

Re: Plugin - Wan IP Checker

Post by Teknor » Sunday 29 October 2017 22:44

When installing the plugin I get the following error and Domoticz will not start. Kind of strange that my GPIO export settings will make the script fail?

All help is appreciated. Thanks.

Code: Select all

pi@raspberrypi:~/domoticz/plugins $ sudo service domoticz.sh status
● domoticz.service - LSB: Home Automation System
   Loaded: loaded (/etc/init.d/domoticz.sh)
   Active: active (exited) since sø. 2017-10-29 21:37:23 CET; 3min 7s ago
  Process: 576 ExecStart=/etc/init.d/domoticz.sh start (code=exited, status=0/SUCCESS)

okt. 29 21:37:23 raspberrypi sudo[861]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/sh -c echo 27 > /sys/class/gpio/export
okt. 29 21:37:23 raspberrypi sudo[861]: pam_unix(sudo:session): session opened for user root by (uid=0)
okt. 29 21:37:23 raspberrypi sudo[861]: pam_unix(sudo:session): session closed for user root
okt. 29 21:37:23 raspberrypi sudo[874]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/sh -c echo high > /sys/class/gpio/gpio27/direction
okt. 29 21:37:23 raspberrypi sudo[874]: pam_unix(sudo:session): session opened for user root by (uid=0)
okt. 29 21:37:23 raspberrypi sudo[874]: pam_unix(sudo:session): session closed for user root
okt. 29 21:37:23 raspberrypi sudo[886]: root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/sh -c echo 1 > /sys/class/gpio/gpio27/active_low
okt. 29 21:37:23 raspberrypi sudo[886]: pam_unix(sudo:session): session opened for user root by (uid=0)
okt. 29 21:37:23 raspberrypi sudo[886]: pam_unix(sudo:session): session closed for user root
okt. 29 21:37:23 raspberrypi systemd[1]: Started LSB: Home Automation System.
Raspberry Pi 3 running RFXTRX433e Mysensors NRF24L01 MotionEYE - Raspberry Pi 2 running Pikrellcam

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

Re: Plugin - Wan IP Checker

Post by manjh » Sunday 28 January 2018 19:46

I installed this following the instructions. Logged in and then did sudo su.
Created the plugin.py in a new subdir under "plugins".
Restarted Domoticz. No errors, but I don't see the WAN checker in the hardware setup dropdown...
Hans

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

Re: Plugin - Wan IP Checker

Post by ycahome » Sunday 28 January 2018 21:00

manjh wrote:
Sunday 28 January 2018 19:46
I installed this following the instructions. Logged in and then did sudo su.
Created the plugin.py in a new subdir under "plugins".
Restarted Domoticz. No errors, but I don't see the WAN checker in the hardware setup dropdown...
Hi there.

Do you have any other python plugins?
D you have python properly installed?

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

Re: Plugin - Wan IP Checker

Post by manjh » Sunday 28 January 2018 23:34

ok
tell me how to check pls.
Hans

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

Re: Plugin - Wan IP Checker

Post by ycahome » Monday 29 January 2018 9:30

manjh wrote:
Sunday 28 January 2018 23:34
ok
tell me how to check pls.

Code: Select all

# from https://www.domoticz.com/wiki/Using_Python_plugins

# install dependencies
sudo apt-get install -y python3

# Domoticz Beta versions since V3.6129 also require...
sudo apt-get install -y python3-dev


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

Re: Plugin - Wan IP Checker

Post by manjh » Monday 29 January 2018 14:04

ycahome wrote:
Monday 29 January 2018 9:30
manjh wrote:
Sunday 28 January 2018 23:34
ok
tell me how to check pls.

Code: Select all

# from https://www.domoticz.com/wiki/Using_Python_plugins

# install dependencies
sudo apt-get install -y python3

# Domoticz Beta versions since V3.6129 also require...
sudo apt-get install -y python3-dev

OK, this tells me how to install. But how can I check if it is already installed or not?
Hans

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

Re: Plugin - Wan IP Checker

Post by ycahome » Monday 29 January 2018 16:36

manjh wrote:
Monday 29 January 2018 14:04

OK, this tells me how to install. But how can I check if it is already installed or not?
if you try to install, you will be prompted when the package is already installed.

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

Re: Plugin - Wan IP Checker

Post by manjh » Monday 29 January 2018 17:15

Sure enough: that second install did it. I can now add the IP checker in the HW tab. Thanks!
Hans

domoticzag
Posts: 24
Joined: Tuesday 13 September 2016 19:39
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Plugin - Wan IP Checker

Post by domoticzag » Monday 29 January 2018 19:22

Thanks for the plugin, and thanks to the creator :D works great!

Now I would like to do one thing with this script, send myself an email when the WAN IP changes :D, of course, with the IP in the message.

Now I have created this script:
1.PNG
1.PNG (18.27 KiB) Viewed 608 times
But this is the result:
2.PNG
2.PNG (5.2 KiB) Viewed 608 times
Anyone know how I can get the correct utility value in the email/notification?

Thanks!
RPi 3
Domoticz Béta
RFLink Gateway dipool antenna
Many kaku devices
P1 smart meter
Custom made ESP8266 devices
Hue lights / Milight ligts and strips

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

Re: Plugin - Wan IP Checker

Post by manjh » Monday 29 January 2018 19:48

domoticzag wrote:
Monday 29 January 2018 19:22
Thanks for the plugin, and thanks to the creator :D works great!

Now I would like to do one thing with this script, send myself an email when the WAN IP changes :D, of course, with the IP in the message.

Now I have created this script:
1.PNG

But this is the result:
2.PNG
Anyone know how I can get the correct utility value in the email/notification?

Thanks!
I have done exactly that today! Even made sure I only receive one e-mail per day. Otherwise you may wake up with a mailbox full of warnings..
The only thing is: It is not in Blockly, but in LUA. If you have the courage to get into LUA, I can post my small LUA script here...
Hans

domoticzag
Posts: 24
Joined: Tuesday 13 September 2016 19:39
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Plugin - Wan IP Checker

Post by domoticzag » Monday 29 January 2018 23:29

manjh wrote:
Monday 29 January 2018 19:48
domoticzag wrote:
Monday 29 January 2018 19:22
Thanks for the plugin, and thanks to the creator :D works great!

Now I would like to do one thing with this script, send myself an email when the WAN IP changes :D, of course, with the IP in the message.

Now I have created this script:
1.PNG

But this is the result:
2.PNG
Anyone know how I can get the correct utility value in the email/notification?

Thanks!
I have done exactly that today! Even made sure I only receive one e-mail per day. Otherwise you may wake up with a mailbox full of warnings..
The only thing is: It is not in Blockly, but in LUA. If you have the courage to get into LUA, I can post my small LUA script here...



It may post several times an hour, but only if the WAN does actually change, thats why I made the user variable. But I dont understand why this doesnt work, even when I email the utility it just saids utility(358) instead of the actual value.

But if you could post it, I would much appreciate !

Thanks!

It would actually be smoother to integrate this functionality into the Plugin itself. I would need to do some Python exercises first, I am an experienced C programmer but this is just a little bit different.
RPi 3
Domoticz Béta
RFLink Gateway dipool antenna
Many kaku devices
P1 smart meter
Custom made ESP8266 devices
Hue lights / Milight ligts and strips

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

Re: Plugin - Wan IP Checker

Post by manjh » Monday 29 January 2018 23:53

You could have the e-mail script triggered by a change in the text device: once the WAN address changes, the plugin will change the text and it would then trigger the mail. Probably. It makes the whole mechanism somewhat easier, and it will result in one single e-mail after a change of the WAN address. But I want to have one mail per day, in case I miss a warning mail. It will keep sending the daily mail, until I have changed my DNS entry and also stored the new IP address in my user variable.

My script works like this: I store the currently known WAN address in a user variable, and check that. If it changes, I compose and send an e-mail, and store the date in another user variable. The next time I want to send an email, I check the date: if it is the same I donot send. This way I only get one single warning message per day.

Code dependency:
two user variables (type string):
"WAN IP" contains the last known WAN IP address
"WAN IP Warning sent" contains the date on which a warning was sent (to make sure one warning is sent per day, not more/less)
one text device, as created by the plugin, named "WAN IP".

Code: Select all

-- This script will periodically check if the WAN IP is changed

commandArray = {}

-- get stored WAN IP address
VAR_IP = uservariables['WAN IP']
-- get current WAN IP address
WAN_IP = otherdevices_svalues['WAN IP']

-- check if current WAN IP address has changed
if (VAR_IP ~= WAN_IP) then 
    -- check if warning was already sent today
    curr_date = os.date('%Y-%m-%d')
    sent_date = uservariables['WAN IP Warning sent']
    if (sent_date ~= curr_date) then
        print ("Warning! WAN IP has changed!")
        
        -- compose text for warning e-mail
        Subject = "WAP IP address has changed"
        Body = " The WAN IP address in De Meern seems to have changed. Previous address was "..VAR_IP..". Current address is "..WAN_IP..". Please check, and change the DNS entry at Hostnet."
        -- send warning e-mail to admin (address is stored in uservariable AdminMail)
        commandArray['SendEmail'] = Subject .. "#" .. Body .. "#" .. uservariables['AdminMail']
 
        -- store current date to indicate warning has been sent
        commandArray['Variable:WAN IP Warning sent'] = curr_date
    end
else 
    -- clear warning sent field, if necessary
    if (uservariables['WAN IP Warning sent'] ~= ".") then
        commandArray['Variable:WAN IP Warning sent'] = "."
    end 
end

return commandArray
Last edited by manjh on Tuesday 30 January 2018 0:05, edited 3 times in total.
Hans

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests