Disable Switch use certain times of day? Topic is solved

Moderator: leecollings

Post Reply
Pauldc
Posts: 9
Joined: Friday 13 January 2017 12:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Disable Switch use certain times of day?

Post 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 :)
User avatar
waltervl
Posts: 5152
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Disable Switch use certain times of day?

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Disable Switch use certain times of day?

Post 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&param=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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Pauldc
Posts: 9
Joined: Friday 13 January 2017 12:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Disable Switch use certain times of day?

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

Re: Disable Switch use certain times of day?

Post 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
openURL.png (6.37 KiB) Viewed 1675 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Pauldc
Posts: 9
Joined: Friday 13 January 2017 12:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Disable Switch use certain times of day?

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

Re: Disable Switch use certain times of day?

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
sieth
Posts: 33
Joined: Wednesday 15 November 2017 19:40
Target OS: Linux
Domoticz version: 2020.2
Location: Belgium
Contact:

Re: Disable Switch use certain times of day?

Post by sieth »

Can you discribe the setup?

What type of switch do you use?
Zwave, zigbee, shelly?
Pauldc
Posts: 9
Joined: Friday 13 January 2017 12:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Disable Switch use certain times of day?

Post 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?
Pauldc
Posts: 9
Joined: Friday 13 January 2017 12:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Disable Switch use certain times of day?

Post 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
Screenshot 2021-03-09 at 14.00.16.png (163.75 KiB) Viewed 1630 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.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Disable Switch use certain times of day?

Post 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
Blockly 20210309 Disable device.png (33.81 KiB) Viewed 1621 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&amp;param=setdevused&amp;idx=2651&amp;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&amp;param=setdevused&amp;idx=2651&amp;used=true</field></block></value></block></statement></block></xml>

Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Pauldc
Posts: 9
Joined: Friday 13 January 2017 12:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Disable Switch use certain times of day?

Post 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&amp;param=setdevused&amp;idx=2651&amp;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&amp;param=setdevused&amp;idx=2651&amp;used=true</field></block></value></block></statement></block></xml>

User avatar
waltervl
Posts: 5152
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Disable Switch use certain times of day?

Post 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?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Pauldc
Posts: 9
Joined: Friday 13 January 2017 12:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Disable Switch use certain times of day?

Post 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&param=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?
User avatar
waltervl
Posts: 5152
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Disable Switch use certain times of day?

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Pauldc
Posts: 9
Joined: Friday 13 January 2017 12:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Disable Switch use certain times of day?

Post 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.
User avatar
waltervl
Posts: 5152
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Disable Switch use certain times of day?

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Disable Switch use certain times of day?

Post 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 )
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

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