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

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
sazaki
Posts: 8
Joined: Thursday 11 February 2021 8:33
Target OS: Linux
Domoticz version:
Contact:

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

Post 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.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

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

Post 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
sazaki
Posts: 8
Joined: Thursday 11 February 2021 8:33
Target OS: Linux
Domoticz version:
Contact:

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

Post by sazaki »

Thank you very much. It works.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest