Disable switch via JSON
Moderator: leecollings
-
- Posts: 15
- Joined: Tuesday 05 April 2016 22:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Disable switch via JSON
I was wondering whether it is possible to temporarily disable a switch through scripting.
Here's my situation:
- I have a window that has a roller shutter mounted on the outside, which can be operated through Domoticz and also has a fixed timer to close at night.
- My window can be opened, in this case the shutter should never operate (else the roller shutter will get damaged, this already happened once).
- My window has a magnetic sensor that can detect whether the window is open or closed.
Ideally i would like to use JSON scripting to set a property for the shutter switch that blocks all operations (manual control, macros and timers) when the window is opened.
I know that it is possible to disable the execution of timers, but this is only a partial solution for me (doesn't affect manual control or macros).
Also i could include a virtual switch that first checks the sensor status and then operates the shutter device, but I consider this a dirty solution.
I already tried using an 'On action' for the shutter that quickly opens it again when the window sensor is triggered, but this was unreliable.
Any suggestions?
Here's my situation:
- I have a window that has a roller shutter mounted on the outside, which can be operated through Domoticz and also has a fixed timer to close at night.
- My window can be opened, in this case the shutter should never operate (else the roller shutter will get damaged, this already happened once).
- My window has a magnetic sensor that can detect whether the window is open or closed.
Ideally i would like to use JSON scripting to set a property for the shutter switch that blocks all operations (manual control, macros and timers) when the window is opened.
I know that it is possible to disable the execution of timers, but this is only a partial solution for me (doesn't affect manual control or macros).
Also i could include a virtual switch that first checks the sensor status and then operates the shutter device, but I consider this a dirty solution.
I already tried using an 'On action' for the shutter that quickly opens it again when the window sensor is triggered, but this was unreliable.
Any suggestions?
Domoticz on RPi3 + mochad + razberry + RFXCom.
Devices: lamps / blinds / curtains / alarm.
Controls: iOS app / RF remote.
TBD: ir TV remote control, presence detection.
Devices: lamps / blinds / curtains / alarm.
Controls: iOS app / RF remote.
TBD: ir TV remote control, presence detection.
-
- Posts: 115
- Joined: Sunday 11 January 2015 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Disable switch via JSON
Why do you consider the virtual switch solution as dirty? I think, in combination with a script or blocky, that's the way to go.
- Egregius
- Posts: 2589
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Disable switch via JSON
I would have guessed these commands:
Unfortunaly there's a bug, the second command doesn't disable the device, it removes the device entirely! Wish I tested with a unused device, now I have to exclude/include again...
Anyway, when u use the developer view of a good browser you should be able to find the commands.
A bit more fiddling gave me these:
When the switch is 'protected' you can't switch it anymore. Don't know how LUA/blockly responds to this, the JSON api requires the pincode to switch.
Code: Select all
http://192.168.2.10:8084/json.htm?type=setused&idx=329&used=true
http://192.168.2.10:8084/json.htm?type=setused&idx=329&used=false
Anyway, when u use the developer view of a good browser you should be able to find the commands.
A bit more fiddling gave me these:
Code: Select all
http://192.168.2.10:8084/json.htm?type=setused&idx=328&protected=false&used=true
http://192.168.2.10:8084/json.htm?type=setused&idx=328&protected=true&used=true
-
- Posts: 15
- Joined: Tuesday 05 April 2016 22:22
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Disable switch via JSON
You're a life-saver!Egregius wrote: Anyway, when u use the developer view of a good browser you should be able to find the commands.
A bit more fiddling gave me these:When the switch is 'protected' you can't switch it anymore. Don't know how LUA/blockly responds to this, the JSON api requires the pincode to switch.Code: Select all
http://192.168.2.10:8084/json.htm?type=setused&idx=328&protected=false&used=true http://192.168.2.10:8084/json.htm?type=setused&idx=328&protected=true&used=true
This set of commands works excellent for disabling/enabling operation of the switch.
I found out that the timers are still fired with protected=true, therefor i added a command to temporarily disable all timers of the device as well.
This was exactly what i was looking for, problem fixed!
Domoticz on RPi3 + mochad + razberry + RFXCom.
Devices: lamps / blinds / curtains / alarm.
Controls: iOS app / RF remote.
TBD: ir TV remote control, presence detection.
Devices: lamps / blinds / curtains / alarm.
Controls: iOS app / RF remote.
TBD: ir TV remote control, presence detection.
Re: Disable switch via JSON
You can set device unused, with this command:
http://192.168.2.10:8084/json.htm?type=setunused&idx=6
http://192.168.2.10:8084/json.htm?type=setunused&idx=6
-
- Posts: 30
- Joined: Tuesday 25 June 2019 13:18
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Disable switch via JSON
Dear all,
I know this is an old topic, but i'm planning to do the exact same thing as TS.
Plan is to block scripts and switches for closing blinds in Domoticz when the windows are open. I allready had a damaged blind when my little daughter get the hand at a switch
. Idea is to use 433mhz windowsensors from China.
I'm not a programmer, but learning Blockly a little bid. JSON is completely new for me and I have no idea how to use this.
Can someone explain what the best (easiest?) way is to implement this in my situation?
I'm using Domoticz on a Synology 213 and a RFXCOM.
I know this is an old topic, but i'm planning to do the exact same thing as TS.
Plan is to block scripts and switches for closing blinds in Domoticz when the windows are open. I allready had a damaged blind when my little daughter get the hand at a switch

I'm not a programmer, but learning Blockly a little bid. JSON is completely new for me and I have no idea how to use this.
Can someone explain what the best (easiest?) way is to implement this in my situation?
I'm using Domoticz on a Synology 213 and a RFXCOM.
-
- Posts: 30
- Joined: Tuesday 25 June 2019 13:18
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Disable switch via JSON
Ordered a KERUI sensor, but still looking for a way to program this. What do you guys think is best?
-
- Posts: 30
- Joined: Tuesday 25 June 2019 13:18
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Disable switch via JSON
I did the same thing and the individual switch of the blind is disabled the right way. So far so good. But the groups with the same switch (blind) in it keeps working, so that is a problem. What is the best solution to disable the switch AND the group. Or better: only disable the blind of the window in the group which is open at that moment.nfaber wrote: ↑Monday 06 March 2017 18:33You're a life-saver!Egregius wrote: Anyway, when u use the developer view of a good browser you should be able to find the commands.
A bit more fiddling gave me these:When the switch is 'protected' you can't switch it anymore. Don't know how LUA/blockly responds to this, the JSON api requires the pincode to switch.Code: Select all
http://192.168.2.10:8084/json.htm?type=setused&idx=328&protected=false&used=true http://192.168.2.10:8084/json.htm?type=setused&idx=328&protected=true&used=true
This set of commands works excellent for disabling/enabling operation of the switch.
I found out that the timers are still fired with protected=true, therefor i added a command to temporarily disable all timers of the device as well.
This was exactly what i was looking for, problem fixed!
Anyone who can put me in the right direction?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Disable switch via JSON
Don''t think the best solution for this is to set a device to unused but if you cannot prevent the triggering of the device in another way:
API for setting a device to unused:
Code: Select all
http://<domoticzIP:domoticzPort>/json.htm?idx=<IDX>¶m=setunused&type=command
Code: Select all
http://<domoticzIP:domoticzPort>/json.htm?idx=<IDX>&name=<newName>&type=setused&used=true
Code: Select all
http://<domoticzIP:domoticzPort>/json.htm?idx=<IDX>&type=setused&used=true
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 30
- Joined: Tuesday 25 June 2019 13:18
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Disable switch via JSON
waaren wrote: ↑Sunday 23 August 2020 23:54Don''t think the best solution for this is to set a device to unused but if you cannot prevent the triggering of the device in another way:
API for setting a device to unused:And to set a device back to used:Code: Select all
http://<domoticzIP:domoticzPort>/json.htm?idx=<IDX>¶m=setunused&type=command
orCode: Select all
http://<domoticzIP:domoticzPort>/json.htm?idx=<IDX>&name=<newName>&type=setused&used=true
Code: Select all
http://<domoticzIP:domoticzPort>/json.htm?idx=<IDX>&type=setused&used=true
Thanks for your reply. I allrady managed to set the blinds (switches) to unused via the 'on action' off a dummy. The problem is that the switch keeps active in groups. So when I activate a group, the blind which is set to unused or protected still moves.
Is there a better way to program this?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Disable switch via JSON
My approach would be to control the blinds via dzVents.
in pseudo code:
-- for single blind: create a dummy blind1Control switch
if blind1Control == On then
if window1Contact == Closed then blind1.close else alert 'Window1 still open' end
else
blind1.Open
end
-- For set of blinds: Create an empty blindsControl group
if blindsControlGroup == On then
if window1Contact == Closed then blind1.close else alert 'window 1 still open' end
if window2Contact == Closed then blind2.close else alert 'window 2 still open' end
else
blind1.Open
blind2.Open
end
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 30
- Joined: Tuesday 25 June 2019 13:18
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Disable switch via JSON
Ok. Seems like I have to dig into dzVents. I'm not a programmer at all and everything is new for me. Is it doable for a noob?

- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Disable switch via JSON
Only one way to find out.

I suggest you start with some virtual devices on dummy hardware and ask for help here if your script does not work as expected in that set-up. If everything works as expected rename to the real blinds and contacts.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 30
- Joined: Tuesday 25 June 2019 13:18
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Disable switch via JSON
Well, I tried a lot but can't get Dzvents to work. Nothing happens. I already did the following things:
- Checked settings. (see screenshots)
- Tried the 'testscript' from the Quickstart wiki.
- Tried with a regular switch and a dummy.
Result is nothing in de logs. Only the confirmation of the saving of the script is written.
What am I overlooking?
please help this noob
- Checked settings. (see screenshots)
- Tried the 'testscript' from the Quickstart wiki.
- Tried with a regular switch and a dummy.
Result is nothing in de logs. Only the confirmation of the saving of the script is written.
What am I overlooking?
please help this noob

- Attachments
-
- Naamloos3.jpg (53.7 KiB) Viewed 1698 times
-
- Naamloos2.jpg (85.95 KiB) Viewed 1698 times
-
- Naamloos.jpg (44.68 KiB) Viewed 1698 times
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Disable switch via JSON
You are on a very old version of domoticz. Can you upgrade?
If not try to switch the 'niet actief' selections. I think I remember that something was not translated properly in this version but don't know for sure, which one (or both)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 30
- Joined: Tuesday 25 June 2019 13:18
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Disable switch via JSON
I'm using a Synology 213 NAS and I remember reading this is not supported anymore. Do you know what's the latest version I can use with my hardware?
Everything else works perfect...
I will try to switch the checkboxes of 'niet actief', but the Wiki says they have to be unchecked, so I did.
All other settings are good?
Everything else works perfect...
I will try to switch the checkboxes of 'niet actief', but the Wiki says they have to be unchecked, so I did.
All other settings are good?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Disable switch via JSON
Sorry you will have to ask @jadahl
YesI will try to switch the checkboxes of 'niet actief', but the Wiki says they have to be unchecked, so I did.
All other settings are good?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 30
- Joined: Tuesday 25 June 2019 13:18
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: Disable switch via JSON
Finally I managed to got it working. I completely deleted the package and reinstalled the latest package available for my CPU.
I ran the test script from the Wiki and the logs let me know that it works.
Now going to learn some scripting...
I ran the test script from the Wiki and the logs let me know that it works.
Now going to learn some scripting...

Who is online
Users browsing this forum: No registered users and 1 guest