Page 1 of 1
Disable Switch use certain times of day?
Posted: Friday 05 March 2021 12:23
by Pauldc
I have a switch that wants to make unavailable from 12am till 8 am every day but I'm not sure how to set it up, I'm thinking it can't be that hard i just can't really figure the simplest way to get it to work any suggestions would be great
Re: Disable Switch use certain times of day?
Posted: Friday 05 March 2021 14:01
by waltervl
I never heard of such a functionality.
But perhaps you can run a script that disables/enables it but I don't know if there is an API for switching a device enabled/disabled. A quick scan returned nothing in
https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s
Re: Disable Switch use certain times of day?
Posted: Friday 05 March 2021 14:05
by waaren
Pauldc wrote: ↑Friday 05 March 2021 12:23
I have a switch that wants to make unavailable from 12am till 8 am every day but I'm not sure how to set it up, I'm thinking it can't be that hard i just can't really figure the simplest way to get it to work any suggestions would be great
The API to enable / disable a device is
Code: Select all
http://<domoticz ip:domoticz port>/json.htm?type=command¶m=setdevused&idx=<device idx>&used=<true/false>&name=<device name>
You can use this in a dzVents or Lua or any other type of script.
Re: Disable Switch use certain times of day?
Posted: Monday 08 March 2021 1:28
by Pauldc
Thanks for taking the time to help me out not 100% sure how to use the API, my scripts for the most part i have been useing blocky and haven't really used Lua.
Re: Disable Switch use certain times of day?
Posted: Monday 08 March 2021 8:44
by waaren
Pauldc wrote: ↑Monday 08 March 2021 1:28
Not 100% sure how to use the API, my scripts for the most part i have been using blocky
From a blockly script you can use something like
- openURL.png (6.37 KiB) Viewed 1677 times
Re: Disable Switch use certain times of day?
Posted: Tuesday 09 March 2021 1:27
by Pauldc
Thanks for getting back to me
still, no luck if you have time could you really dumb it down seems I feel a bit very lost what I'm thinking,
Have one Switch IDX 2651 that controls a light which I want to disable between 12 am-8 am
waaren wrote: ↑Monday 08 March 2021 8:44
Pauldc wrote: ↑Monday 08 March 2021 1:28
Not 100% sure how to use the API, my scripts for the most part i have been using blocky
From a blockly script you can use something like
openURL.png
Re: Disable Switch use certain times of day?
Posted: Tuesday 09 March 2021 9:53
by waaren
Pauldc wrote: ↑Tuesday 09 March 2021 1:27
still, no luck if you have time could you really dumb it down seems I feel a bit very lost what I'm thinking,
Please share what you actually tried using the openURL in a time based Blockly script.
Re: Disable Switch use certain times of day?
Posted: Tuesday 09 March 2021 11:09
by sieth
Can you discribe the setup?
What type of switch do you use?
Zwave, zigbee, shelly?
Re: Disable Switch use certain times of day?
Posted: Tuesday 09 March 2021 13:56
by Pauldc
Sure
So what I've succeeded with is at the moment when a mobile phone gets close to our home it turns on a switch via an app for geofencing and within that switch on Domoticz, its plays out a sound over our Sonos speaker and that mp3 audio is triggered as a notification all of this works without any problems.
what I would like to achieve now is that the audio is not played out between 00:00 - 08:00
I was thinking of moving the audio/notification to its own switch so the geofencing switch still works but the audio/notification would only be active between said times and link the geofencing mobile switch vi blocky to the separate switch for the audio/notification playout.
Its all hosted on a pi
with zwave, rfxcom 433mhz for most part temps, and sensors most lights via Hue
sieth wrote: ↑Tuesday 09 March 2021 11:09
Can you discribe the setup?
What type of switch do you use?
Zwave, zigbee, shelly?
Re: Disable Switch use certain times of day?
Posted: Tuesday 09 March 2021 13:58
by Pauldc
Seems I'm not even sure where to start I haven't been able to set a blocky script for this i was thinking something like this but never used json before
- Screenshot 2021-03-09 at 14.00.16.png (163.75 KiB) Viewed 1632 times
waaren wrote: ↑Tuesday 09 March 2021 9:53
Pauldc wrote: ↑Tuesday 09 March 2021 1:27
still, no luck if you have time could you really dumb it down seems I feel a bit very lost what I'm thinking,
Please share what you actually tried using the openURL in a time based Blockly script.
Re: Disable Switch use certain times of day?
Posted: Tuesday 09 March 2021 15:48
by waaren
Pauldc wrote: ↑Tuesday 09 March 2021 13:58
Seems I'm not even sure where to start I haven't been able to set a blocky script for this i was thinking something like this but never used json before
Can you try this ?
- Blockly 20210309 Disable device.png (33.81 KiB) Viewed 1623 times
You can import below xml in the event editor (use the +, Blockly, import button, paste below code and save as time triggered)
Code: Select all
<xml xmlns="http://www.w3.org/1999/xhtml"><block type="domoticzcontrols_ifelseif" id="yaJ1v4J{D{d5qvKaWL5M" x="13" y="14"><mutation elseif="1"></mutation><value name="IF0"><block type="logic_timeofday" id="P}IqP(8(ZGLRRSX*jXF$"><field name="OP">EQ</field><value name="Time"><block type="logic_timevalue" id="=k#353ET?9+gn~W=NnxE"><field name="TEXT">00:00</field></block></value></block></value><statement name="DO0"><block type="open_url" id="U=u((isL{0TE)ZVzZga="><value name="urlToOpen"><block type="url_text" id="w,mie_uNr!J*_Z.k_|K9"><field name="TEXT">192.168.1.14:8080/json.htm?type=command&param=setdevused&idx=2651&used=false</field></block></value></block></statement><value name="IF1"><block type="logic_timeofday" id="!=/s@}gG86^sJwoedFI:"><field name="OP">EQ</field><value name="Time"><block type="logic_timevalue" id="J@.|QA?wjQJ;CH0sDCYF"><field name="TEXT">08:00</field></block></value></block></value><statement name="DO1"><block type="open_url" id="T;d`?$~(~,|?EaEt{U`s"><value name="urlToOpen"><block type="url_text" id="l1avg@Tohkn$V#fzM%kQ"><field name="TEXT">192.168.1.14:8080/json.htm?type=command&param=setdevused&idx=2651&used=true</field></block></value></block></statement></block></xml>
Re: Disable Switch use certain times of day?
Posted: Tuesday 09 March 2021 22:44
by Pauldc
Ok yep imported it and have tried it by changing times just so I can test it, but seems if I goto switches and click the switch with that IDX it turns on as normal, anything I'm missing that you can think of?
once again thanks for taking your time to help me
waaren wrote: ↑Tuesday 09 March 2021 15:48
Pauldc wrote: ↑Tuesday 09 March 2021 13:58
Seems I'm not even sure where to start I haven't been able to set a blocky script for this i was thinking something like this but never used json before
Can you try this ?
Blockly 20210309 Disable device.png
You can import below xml in the event editor (use the +, Blockly, import button, paste below code and save as time triggered)
Code: Select all
<xml xmlns="http://www.w3.org/1999/xhtml"><block type="domoticzcontrols_ifelseif" id="yaJ1v4J{D{d5qvKaWL5M" x="13" y="14"><mutation elseif="1"></mutation><value name="IF0"><block type="logic_timeofday" id="P}IqP(8(ZGLRRSX*jXF$"><field name="OP">EQ</field><value name="Time"><block type="logic_timevalue" id="=k#353ET?9+gn~W=NnxE"><field name="TEXT">00:00</field></block></value></block></value><statement name="DO0"><block type="open_url" id="U=u((isL{0TE)ZVzZga="><value name="urlToOpen"><block type="url_text" id="w,mie_uNr!J*_Z.k_|K9"><field name="TEXT">192.168.1.14:8080/json.htm?type=command&param=setdevused&idx=2651&used=false</field></block></value></block></statement><value name="IF1"><block type="logic_timeofday" id="!=/s@}gG86^sJwoedFI:"><field name="OP">EQ</field><value name="Time"><block type="logic_timevalue" id="J@.|QA?wjQJ;CH0sDCYF"><field name="TEXT">08:00</field></block></value></block></value><statement name="DO1"><block type="open_url" id="T;d`?$~(~,|?EaEt{U`s"><value name="urlToOpen"><block type="url_text" id="l1avg@Tohkn$V#fzM%kQ"><field name="TEXT">192.168.1.14:8080/json.htm?type=command&param=setdevused&idx=2651&used=true</field></block></value></block></statement></block></xml>
Re: Disable Switch use certain times of day?
Posted: Tuesday 09 March 2021 22:48
by waltervl
You perhaps will have to refresh the switches page to see the device disappear if disabled.
To test de link: If you copy past the url in a webbrowser it will also enable/disable the device, does it work?
Re: Disable Switch use certain times of day?
Posted: Tuesday 09 March 2021 22:55
by Pauldc
Ok tested to post from web browsers but it revies an error
status "ERR"
in the log it shows as "EventSystem: Fetching URL 192.168.1.14:8080/json.htm?type=command¶m=setdevused&idx=2651&used=false after 0.2 seconds..."
waltervl wrote: ↑Tuesday 09 March 2021 22:48
You perhaps will have to refresh the switches page to see the device disappear if disabled.
To test de link: If you copy past the url in a webbrowser it will also enable/disable the device, does it work?
Re: Disable Switch use certain times of day?
Posted: Wednesday 10 March 2021 0:30
by waltervl
Are you sure the idx is 2651 because that seems a high number. See the idx column in menu setup - devices.
Did you try the other status too: true or false? Could perhaps giving an error if it was already that status.
Re: Disable Switch use certain times of day?
Posted: Wednesday 10 March 2021 0:38
by Pauldc
Checked the IDX its correct think over the years my DB over devices has picked up a lot of stuff that not used anymore, and also tried the status check both ways like you suggested but no different reports back status error.
waltervl wrote: ↑Wednesday 10 March 2021 0:30
Are you sure the idx is 2651 because that seems a high number. See the idx column in menu setup - devices.
Did you try the other status too: true or false? Could perhaps giving an error if it was already that status.
Re: Disable Switch use certain times of day?
Posted: Wednesday 10 March 2021 0:56
by waltervl
I tried it myself on a device and I get the same ERR status back.
@waaren, can you check? i am on:
Version: 2020.2 (build 12901)
Build Hash: b6dc22e8b-modified
Compile Date: 2021-02-01 17:52:08
dzVents Version: 3.1.4
Re: Disable Switch use certain times of day?
Posted: Wednesday 10 March 2021 2:09
by waaren
waltervl wrote: ↑Wednesday 10 March 2021 0:56
I tried it myself on a device and I get the same ERR status back.
@waaren, can you check? i am on:
I checked on latest beta. It works ok This API was implemented in build 12921 (see the
wiki page with all commit descriptions )