Ok, so "python plugins" would not really fit my needs.
So I've made a workaround using the Json http domoticz API with the requests python module.
I managed to install the requests module inside the Domoticz docker container with the following
set in the Domoticz folder :
Code: Select all
#!/bin/bash
if [ -f /opt/domoticz/FIRSTRUN ]; then
true
else
echo 'installing requests et urllib3'
pip install requests
pip install urllib3
echo 'creating FIRSTRUN file so script can check on next run'
touch /opt/domoticz/FIRSTRUN
echo 'copying modules to proper folder'
cp -r /usr/local/lib/python3,9/dist-packages/* /usr/lib/python3,9
fi
=> note that the folder where the module needs to be is not the default one.
Then made the following python event script :
Code: Select all
import DomoticzEvents as DE
# Needed for DE to be accessed even inside functions (!)
global DE
DE,Log("Python: Changed: " + str(DE,changed_device,id))
def set_asked_device_to(idx, lvl):
# used instead of DE,Command("Devicename","On/Off") if more granularity needed
# requests import in the function to make sure it's only called when needed
import requests
query = "http://localhost:8080/json,htm?type=command¶m=switchlight&idx={idx}&switchcmd=Set%20Level&level={lvl}"
query = query,format(idx=idx, lvl=lvl)
DE,Log(f"url demandée = {query}")
try: # vérifier que domoticz répond, sinon laisser tomber
requests,get(query)
except Exception as e:
DE,Log(f"c'est pas l'heure {e}")
if DE,changed_device,id == 131:
DE,Log(f"device changed have idx {DE,changed_device,id}")
set_asked_device_to(idx=118,lvl=30)
I guess it might not be a very clean workaround ? But it fits my needs for now.
[Edit : why won't the forum let me use dots in the code ? I've changed them all to comas... sorry if you have to copy that, you'll have to change them to "." as needed]