I'm trying to use python instead of lua in my latest automation script; so i can learn python. The entire example given when you select python is already generating errors. after some googling i figured out that the wrong module is imported. Now im trying to import the request module but eventough its installed on the system, domoticz keeps giving the error below.
Code: Select all
2021-03-10 15:24:29.584 Error: EventSystem: Failed to execute python event script "Python Test"
2021-03-10 15:24:29.584 Error: EventSystem: Traceback (most recent call last):
2021-03-10 15:24:29.584 Error: EventSystem: File "<string>", line 5, in <module>
2021-03-10 15:24:29.584 Error: EventSystem: ModuleNotFoundError: No module named 'requests'
Code: Select all
>sudo pip3 list
Package Version
------------------- ---------
asn1crypto 0.24.0
certifi 2020.12.5
chardet 4.0.0
cryptography 2.6.1
distro-info 0.21
entrypoints 0.3
idna 2.10
keyring 17.1.1
keyrings.alt 3.1.1
pip 18.1
pycrypto 2.6.1
PyGObject 3.30.4
python-apt 1.8.4.3
pyxdg 0.25
requests 2.25.1
SecretStorage 2.3.1
setuptools 40.8.0
six 1.12.0
unattended-upgrades 0.1
urllib3 1.26.3
wheel 0.32.3
Code: Select all
import DomoticzEvents as DEVS
from datetime import datetime
import requests as REQ
HueIP = '192.168.100.50'
HueUsername = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
for name, value in DEVS.user_variables.items():
if name == 'AlarmTime' :
#DEVS.Log("Python: User-variable '{0}' has value: {1}".format(name, value))
ts = int(value)
test = datetime.utcfromtimestamp(ts).strftime('%Y-%m-%dT%H:%M:%SZ')
DEVS.Log(test)
response = REQ.get("http://"+ HueIP +"/api/"+ HueUsername +"/schedules")
DEVS.Log(response.status_code)
Any suggestions?