I had a problem with the update of my Domoticz device. Every time I set the status of the device twinkly begins from start.
I did a quick and dirty bash script that I pull every minute with crontab:
*/1 * * * * root /home/scott/domoticz/scripts/twinkly.sh status >/dev/null 2>&1
The script twinkly.sh (change your Twinkly IP and Domoticz IDX of your virtual switch)
Code: Select all
#!/bin/bash
case $1 in
on )
/usr/bin/python3 /home/scott/domoticz/scripts/twinkly.py 192.168.178.136 on
;;
off )
/usr/bin/python3 /home/scott/domoticz/scripts/twinkly.py 192.168.178.136 off
;;
status )
state_twinkly=$(/usr/bin/python3 /home/scott/domoticz/scripts/twinkly.py 192.168.178.136 state)
#echo "Status twinkly: $state_twinkly"
state_domoticz=$(curl -s "http://127.0.0.1:8080/json.htm?type=devices&rid=35987" | jq .result[0].Status | sed 's/\"//g')
#echo "echo Domoticz $state_domoticz"
if [ "$state_domoticz" == "On" ]; then
state_domoticz=1
else
state_domoticz=0
fi
#echo "echo Domoticz new $state_domoticz"
if [ "$state_twinkly" == "$state_domoticz" ]; then
exit 0;
else
curl -s "http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=35987&switchcmd=Toggle"
# echo "Ändere Status"
fi
;;
esac
In Domoticz self I configure the Switch to trigger the same script:
Action on: "script://twinkly.sh on"
Action off: "script://twinkly.sh off"
If anybody have a question about it let me know or write pm. I hope everyone can use twinkly over Domoticz now
