Wiki Script, don't work "Python - Monitor Domoticz IP address"
Moderator: leecollings
-
- Posts: 13
- Joined: Wednesday 11 December 2019 15:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Wiki Script, don't work "Python - Monitor Domoticz IP address"
Hi,
I Need to have a IP discovery script and "Python - Monitor Domoticz IP address" looks fine but it dosent work. I think urllib2 is the problem.
Any tips on how to get this to work:
https://www.domoticz.com/wiki/Python_-_ ... IP_address
I Need to have a IP discovery script and "Python - Monitor Domoticz IP address" looks fine but it dosent work. I think urllib2 is the problem.
Any tips on how to get this to work:
https://www.domoticz.com/wiki/Python_-_ ... IP_address
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Wiki Script, don't work "Python - Monitor Domoticz IP address"
The port number was missing from this python script and the script is written for python2. I now updated the wiki script to include the port number and also added a version that works with python3. (converted from the original using the 2to3 tool (sudo apt install 2to3) )bjornsundberg wrote: ↑Friday 18 December 2020 10:52 I Need to have a IP discovery script and "Python - Monitor Domoticz IP address" looks fine but it dosent work. I think urllib2 is the problem.
I tested them successfully on my systems but if it still not OK for you, please include the errors when executed from the command line.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
- erem
- Posts: 230
- Joined: Tuesday 27 March 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Amsterdam/netherlands
- Contact:
Re: Wiki Script, don't work "Python - Monitor Domoticz IP address"
IMHO that script has no purpose.
you publish the new ip address to a sensor you can no longer read, since the ip address has changed.
much better would be an email with the new ip address.
better use a portscanner and scan your network for open port 8080, or whatever port you use. NMAP is a good portscanner
just my S.02
you publish the new ip address to a sensor you can no longer read, since the ip address has changed.
much better would be an email with the new ip address.
better use a portscanner and scan your network for open port 8080, or whatever port you use. NMAP is a good portscanner
just my S.02
Regards,
Rob
Rob
-
- Posts: 13
- Joined: Wednesday 11 December 2019 15:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Wiki Script, don't work "Python - Monitor Domoticz IP address"
Hi, Sorry for not explaining. I will use it to publish to a mqtt broker that recieves the IP adress. Do you know how to fix the script?erem wrote: ↑Sunday 20 December 2020 16:10 IMHO that script has no purpose.
you publish the new ip address to a sensor you can no longer read, since the ip address has changed.
much better would be an email with the new ip address.
better use a portscanner and scan your network for open port 8080, or whatever port you use. NMAP is a good portscanner
just my S.02
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Wiki Script, don't work "Python - Monitor Domoticz IP address"
I fixed the script on the wiki page.bjornsundberg wrote: ↑Sunday 20 December 2020 19:16 Hi, Sorry for not explaining. I will use it to publish to a mqtt broker that recieves the IP adress. Do you know how to fix the script?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 13
- Joined: Wednesday 11 December 2019 15:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Wiki Script, don't work "Python - Monitor Domoticz IP address"
Hi,waaren wrote: ↑Friday 18 December 2020 20:47The port number was missing from this python script and the script is written for python2. I now updated the wiki script to include the port number and also added a version that works with python3. (converted from the original using the 2to3 tool (sudo apt install 2to3) )bjornsundberg wrote: ↑Friday 18 December 2020 10:52 I Need to have a IP discovery script and "Python - Monitor Domoticz IP address" looks fine but it dosent work. I think urllib2 is the problem.
I tested them successfully on my systems but if it still not OK for you, please include the errors when executed from the command line.
Just tested with python3 script but this is the results:
pi@raspberrypi:~/domoticz/scripts/python $ python ip_address.py
Traceback (most recent call last):
File "ip_address.py", line 8, in <module>
import urllib.request, urllib.error, urllib.parse
ImportError: No module named request
pi@raspberrypi:~/domoticz/scripts/python $
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Wiki Script, don't work "Python - Monitor Domoticz IP address"
did you trybjornsundberg wrote: ↑Monday 21 December 2020 22:18 Just tested with python3 script but this is the results:
pi@raspberrypi:~/domoticz/scripts/python $ python ip_address.py
Code: Select all
python3 ip_address.py
what do you see when entering
Code: Select all
python --version
python3 --version
python2 --version
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 13
- Joined: Wednesday 11 December 2019 15:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Wiki Script, don't work "Python - Monitor Domoticz IP address"
Hi again,
Running "python3 ip_address.py"
br
Björn
Code: Select all
Version of Python:
pi@RPi3:~/domoticz/scripts/python $ python --version
Python 2.7.16
pi@RPi3:~/domoticz/scripts/python $ python3 --version
Python 3.7.3
pi@RPi3:~/domoticz/scripts/python $ python2 --version
Python 2.7.16
pi@RPi3:~/domoticz/scripts/python $
Running "python3 ip_address.py"
Code: Select all
pi@RPi3:~/domoticz/scripts/python $ python3 ip_address.py
Traceback (most recent call last):
File "ip_address.py", line 27, in <module>
json_object = json.loads(domoticzrequest(domoticzurl)) # retrieve sensor data
File "ip_address.py", line 22, in domoticzrequest
response = urllib.request.urlopen(request)
File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.7/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.7/urllib/request.py", line 641, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.7/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/usr/lib/python3.7/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized
pi@RPi3:~/domoticz/scripts/python $
Björn
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Wiki Script, don't work "Python - Monitor Domoticz IP address"
Seems to be an authorisation issue. (are you authorized to access domoticz without password?)bjornsundberg wrote: ↑Tuesday 22 December 2020 18:58Code: Select all
urllib.error.HTTPError: HTTP Error 401: Unauthorized
Make sure that in the Security section in the settings (Setup > Settings > System > Local Networks (no username/password) you allow 127.0.0.1 (and / or ::1 when using IPv6 ) to not need a password.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: No registered users and 1 guest