Page 1 of 1

Using Domoticz Rest API, how to create a switch with On/Off Action

Posted: Wednesday 24 March 2021 3:51
by sazaki
I can create a switch using the REST API:
http://192.168.18.1:8080/json.htm?type= createdevice & idx=29&sensorname=switch1&devicetype=244&devicesubtype=73
But, I don't know how to use API to fill the "On Action" "Off Action" of the created switch. I would like to have something like http://192.168.18.3/myscripyt1.sh in "On Action" , http://192.168.18.3/myscripyt2.sh in "Off Action".

Any help or advice is appreciated.

Re: Using Domoticz Rest API, how to create a switch with On/Off Action

Posted: Wednesday 24 March 2021 7:30
by waaren
sazaki wrote: Wednesday 24 March 2021 3:51 I don't know how to use API to fill the "On Action" "Off Action" of the created switch.
I would like to have something like http://192.168.18.3/myscripyt1.sh in "On Action" , http://192.168.18.3/myscripyt2.sh in "Off Action".
You can use the "setused" REST API where the actions are base64 encoded in strparam1 and strparam2
something like

Code: Select all

http://<domoticz ip:domoticz port>/json.htm?type=setused&used=true&idx=IDX&strparam1=base64Encoded(ON ACTION STRING)&strparam2=base64Encoded(OFF ACTION STRING)


http://<domoticz ip:domoticz port>/json.htm?type=setused&used=true&idx=<your idx>&strparam1=aHR0cDovLzE5Mi4xNjguMTguMy9teXNjcmlweXQxLnNo&strparam2=aHR0cDovLzE5Mi4xNjguMTguMy9teXNjcmlweXQyLnNo

Re: Using Domoticz Rest API, how to create a switch with On/Off Action

Posted: Wednesday 24 March 2021 13:41
by sazaki
Thank you very much. It works.