Page 3 of 9

Re: Plugin - Wan IP Checker

Posted: Saturday 02 September 2017 18:40
by poudenes
when this error pop up it also let crash other python scripts. Need to restart Domoticz to let it run ok again

Re: Plugin - Wan IP Checker

Posted: Monday 04 September 2017 9:36
by ycahome
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,

Re: Plugin - Wan IP Checker

Posted: Monday 04 September 2017 10:39
by ycahome
#1st Post Updated with the new version.
-Improve: Timeout added to prevent stale url requests.

Re: Plugin - Wan IP Checker

Posted: Friday 15 September 2017 22:17
by EdwinK
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

Re: Plugin - Wan IP Checker

Posted: Sunday 17 September 2017 10:15
by ycahome
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?

Re: Plugin - Wan IP Checker

Posted: Sunday 17 September 2017 12:30
by EdwinK
Used the latest version, running on Synology.

Re: Plugin - Wan IP Checker

Posted: Sunday 17 September 2017 13:47
by Dnpwwo
@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.

Re: Plugin - Wan IP Checker

Posted: Sunday 17 September 2017 18:22
by EdwinK
Thanks. Will ignore it then.

Re: Plugin - Wan IP Checker

Posted: Sunday 29 October 2017 21:44
by Teknor
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.

Re: Plugin - Wan IP Checker

Posted: Sunday 28 January 2018 18:46
by manjh
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...

Re: Plugin - Wan IP Checker

Posted: Sunday 28 January 2018 20:00
by ycahome
manjh wrote: Sunday 28 January 2018 18: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?

Re: Plugin - Wan IP Checker

Posted: Sunday 28 January 2018 22:34
by manjh
ok
tell me how to check pls.

Re: Plugin - Wan IP Checker

Posted: Monday 29 January 2018 8:30
by ycahome
manjh wrote: Sunday 28 January 2018 22: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


Re: Plugin - Wan IP Checker

Posted: Monday 29 January 2018 13:04
by manjh
ycahome wrote: Monday 29 January 2018 8:30
manjh wrote: Sunday 28 January 2018 22: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?

Re: Plugin - Wan IP Checker

Posted: Monday 29 January 2018 15:36
by ycahome
manjh wrote: Monday 29 January 2018 13: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.

Re: Plugin - Wan IP Checker

Posted: Monday 29 January 2018 16:15
by manjh
Sure enough: that second install did it. I can now add the IP checker in the HW tab. Thanks!

Re: Plugin - Wan IP Checker

Posted: Monday 29 January 2018 18:22
by domoticzag
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 2095 times
But this is the result:
2.PNG
2.PNG (5.2 KiB) Viewed 2095 times
Anyone know how I can get the correct utility value in the email/notification?

Thanks!

Re: Plugin - Wan IP Checker

Posted: Monday 29 January 2018 18:48
by manjh
domoticzag wrote: Monday 29 January 2018 18: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...

Re: Plugin - Wan IP Checker

Posted: Monday 29 January 2018 22:29
by domoticzag
manjh wrote: Monday 29 January 2018 18:48
domoticzag wrote: Monday 29 January 2018 18: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.

Re: Plugin - Wan IP Checker

Posted: Monday 29 January 2018 22:53
by manjh
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