First: welcome to this forum!
I think the Python script is perfectly usable with Domoticz.
Put the script on your Pi (domoticz folder > scripts).
Then create a virtual switch (create dummy hardware at Setup > Hardware), then go to 'Switches' tab and click on 'Manual switch'. Choose the dummy hardware from dropdown. Then fill in a name and choose on/off. Protocol doesn't matter because it is virtual.
Then when you have made the switch, click the 'Edit' button and at the 'On action', fill in something like this:
Code: Select all
script://path_to_script/relay.py 8 1
For the 'Off action' you fill in almost the same, but this time the off command:
Code: Select all
script://path_to_script/relay.py 8 0
(not sure if zero means off, but it probably does)
Hope you can get it working that way
Edit: Looked at the Python script again, but i think his blog messes up the code. The '&', '<' and ' " ' are replaced by HTML alternatives.
Try this version that i corrected:
relay.py
Code: Select all
from socket import *
import sys
if len(sys.argv) != 3:
sys.exit(2)
relay = str(sys.argv[1])
state = str(sys.argv[2])
data_send = "FD0220"
if int(relay) <= 8:
data_send += "0" + relay
if int(state) == 0:
data_send += "00"
elif int(state) == 1:
data_send += "01"
elif int(relay) == 9:
data_send += "F8"
if int(state) == 0:
data_send += "80"
elif int(state) == 1:
data_send += "88"
data_send += "5D"
s = socket(AF_INET, SOCK_STREAM)
s.connect(("192.168.1.4", 30000))
s.send(data_send.decode('hex'))
data = s.recv(4)
print(data.encode('hex'))
Be sure to change the IP to that of your board.
I am not active on this forum anymore.