Page 1 of 2
Enable / Disable all events in a switch planning alltogether
Posted: Wednesday 13 January 2016 9:16
by oliviers
Hi,
It would be nice to have the possibility to enable or disable all events in a switch planning at once. Currently, one must activate or deactivate events one by one.
Example of possible usage :
- Disable all events for a heating device during the summer / enable them in the winter
- Disable the watering of my land when it rains
- Disable a switch when not in use (ex: my Christmas tree lights)
Or is there already a way to do this ?
Thank you to the developers of this superb software, anyway.
Oliviers
Re: Enable / Disable all events in a switch planning alltoge
Posted: Wednesday 13 January 2016 10:09
by Eduard
I use a bash-script to enable/disable timers via json.
Available methods are:
* enabletimer
* disabletimer
* enablescenetimer
* disablescenetimer
Use like:
http://<ip>:<port>/json.htm?type=command¶m=enabletimer&idx=<id>
Good luck!
Re: Enable / Disable all events in a switch planning alltoge
Posted: Wednesday 13 January 2016 15:09
by pvm
Possible other solutions
oliviers wrote:
- Disable all events for a heating device during the summer / enable them in the winter
Make the actions temperature dependent using blockly
oliviers wrote:
- Disable the watering of my land when it rains
Measure soil moisture, or rain or retrieve rain from buienradar
oliviers wrote:
- Disable a switch when not in use (ex: my Christmas tree lights)
Switch Christmastree based on date and time using blockly
Re: Enable / Disable all events in a switch planning alltoge
Posted: Wednesday 13 January 2016 18:20
by oliviers
Mmmmm.....
Thanks for the suggestions, but it isn't that easy....
For example, I can't just rely of the ground moisture for watering my land.... Even if it is very dry, I may want to turn watering off because I know that rain is coming tomorrow, for example. Or because I don't want to let it run when I'm away (what if the valve doesn't switch off for some reason??)
There are other cases where I would just like to "disable" a switch and all related actions temporarily. Ex: Don't turn that light on (my Chistmas tree!) because I'm away from home for the weekend.
Furthermore, calculations in Blockry are somehow difficult and cumbersome.... Never been able to do something reliable and ended up writing a Lua script.
It would be easier to just have a check box "switch active or not", isn't it ??? Or scenario/scene active or not.
Oliviers
Re: Enable / Disable all events in a switch planning alltoge
Posted: Wednesday 13 January 2016 18:50
by Egregius
Just use some dummy switches. Easy and very reliable.
Re: Enable / Disable all events in a switch planning alltoge
Posted: Wednesday 13 January 2016 22:43
by oliviers
Could you please elaborate a little bit ? How can I do that with a dummy switch ? And without having to write tens of Lua scripts ..?
Re: Enable / Disable all events in a switch planning alltoge
Posted: Thursday 14 January 2016 7:33
by Egregius
Well, you create a dummy switch and then use that status in blockly/lua/php/... to act on it.
Example:
Switch "Heating" -> If Heating == On set setpoint 20...
Switch "Rainexpected" -> If Rainexpected == Off switch watering on
If you want some more advanced stuff you'll have to code some blockly/lua/php scripts.
I handle EVERYTHING with one PHP file.
Re: Enable / Disable all events in a switch planning alltoge
Posted: Thursday 14 January 2016 8:30
by jannl
I use a dummy switch called Override. When I (or someone else) sets this to On, events are not handled anymore.
Every event has a check for this switch.
Comes in very usefull when I missed/made a program error or missed some special situation to prevent things from happening.
Or when the daily schedule is completely different because of some situation.
Re: Enable / Disable all events in a switch planning alltoge
Posted: Thursday 14 January 2016 13:32
by oliviers
OK, and thanks for your suggestions !
I agree with you that I can solve my problem by writing scripts. Although the scripts could be quite complex. For some of my switches, I have ten or more scheduled events which would all need to be activated or deactivated. It's not, like you wrote, Egregius, "switch watering off", but rather "Do not execute any of the twelve events that I have declared in the switch "planning" screen. Not the one scheduled at 20:00, not the one scheduled at 20:15, not the one scheduled at 20:30, .... and so forth.
So, back to my original suggestion: It would be nice to have a checkbox, in the switch configuration panel, which would globally enable or disable the switch and all its related events. Would be easier and more accessible for non-programmers than writing scripts, isn't it ???
Best regards,
Oliviers
Re: Enable / Disable all events in a switch planning alltoge
Posted: Saturday 16 January 2016 19:16
by oliviers
Hi everybody,
Finally I found a solution to do this.... Update the switch configuration in the domoticz.db database directly.
1. I started by installing sqlite3 on my raspberry pi:
Code: Select all
sudo apt-get update
sudo apt-get install sqlite3
2. I wrote two bash scripts, one to turn all events from my real switch to "Active", the other one to turn them to "Inactive": (in this example, "Talus" is the name of my real switch)
Code: Select all
#!/bin/bash
sqlite3 /home/pi/domoticz/domoticz.db 'update timers set active=1 where devicerowid in (select id from devicestatus where name = "Talus");'
and
Code: Select all
#!/bin/bash
sqlite3 /home/pi/domoticz/domoticz.db 'update timers set active=0 where devicerowid in (select id from devicestatus where name = "Talus");'
3. I created a Virtual switch and assigned these two scripts to "Action On" and "Action off":

- Capture1.PNG (55.65 KiB) Viewed 7421 times
4. When that virtual switch is turned ON, all planning events of the real switch are activated:

- Capture2.PNG (24.89 KiB) Viewed 7421 times
....and they are deactivated when that virtual swith is set to OFF:

- Capture3.PNG (24.5 KiB) Viewed 7421 times
Looks like my "problem" is solved !
Best regards to all, and sorry for the screenshots in French!
Oliviers
Re: Enable / Disable all events in a switch planning alltogether
Posted: Thursday 07 April 2016 9:11
by Number8
I use a bash-script to enable/disable timers via json.
Available methods are:
* enabletimer
* disabletimer
* enablescenetimer
* disablescenetimer
This does not work for SetPoint thermostat. I noticed that the javascript function is updateSetpointTimer, so I tried enablesetpointtimer and enabletimer as well, but it does not work. Any clue what would be the right method if any?
Re: Enable / Disable all events in a switch planning alltogether
Posted: Thursday 07 April 2016 9:59
by Eduard
Number8 wrote:I use a bash-script to enable/disable timers via json.
Available methods are:
* enabletimer
* disabletimer
* enablescenetimer
* disablescenetimer
This does not work for SetPoint thermostat. I noticed that the javascript function is updateSetpointTimer, so I tried enablesetpointtimer and enabletimer as well, but it does not work. Any clue what would be the right method if any?
I think it was not implemented. I will look into that...
Re: Enable / Disable all events in a switch planning alltogether
Posted: Thursday 07 April 2016 10:31
by Number8
Great, thank you
Re: Enable / Disable all events in a switch planning alltogether
Posted: Thursday 07 April 2016 14:02
by Eduard
Number8 wrote:Great, thank you
yw
PullRequest already commited:
https://github.com/domoticz/domoticz/pull/600
Should be available in next beta.
Re: Enable / Disable all events in a switch planning alltogether
Posted: Thursday 07 April 2016 14:10
by Number8
Thanks Eduard, I'll wait next beta, should'nt take that long
Shall I use enabletimer in the JSON request as for the switch timer or another keyword?
Cheers
Re: Enable / Disable all events in a switch planning alltogether
Posted: Thursday 07 April 2016 14:18
by Eduard
Number8 wrote:
Shall I use enabletimer in the JSON request as for the switch timer or another keyword?
The available methods are
* enabletimer
* disabletimer
* enablescenetimer
* disablescenetimer
* enablesetpointtimer (*)
* disablesetpointtimer (*)
[EDIT] (*) Available in next beta
Re: Enable / Disable all events in a switch planning alltogether
Posted: Saturday 09 April 2016 8:10
by Eduard
New beta is availanle. Does it work?
Re: Enable / Disable all events in a switch planning alltogether
Posted: Saturday 09 April 2016 8:21
by Number8
I just upgraded this early morning. Both functions work just great. Thanks Eduard.
Re: Enable / Disable all events in a switch planning alltogether
Posted: Saturday 09 April 2016 9:39
by Eduard
Number8 wrote:I just upgraded this early morning. Both functions work just great. Thanks Eduard.

Re: Enable / Disable all events in a switch planning alltogether
Posted: Wednesday 14 September 2016 1:40
by maluko
is the disablescenetimer/enablescenetimer working fine?
i cant get this working.
the status are fine but the timer dont change.
{
status: "OK",
title: "DisableSceneTimer"
}
thanks