Hoe to disable/enable a timer in a scene from another ??

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.
Post Reply
cyberbob
Posts: 33
Joined: Monday 02 March 2015 15:46
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Hoe to disable/enable a timer in a scene from another ??

Post by cyberbob » Tuesday 04 August 2015 21:19

I have a virtual switch in domoticz.. which goes on and off through an json command and with an ios app.
This to tell the system if im home or not.

Now I also have a couple of scenes with an timer in it. (Trigger a bunch of lights 30 minutes before sunset).

How can I create a blocky script or something, that will do the following:

When I am home.. the timer of scene "A" needs to be active.
When I am away, the timer of scene "A" needs to be inactive.

I already have the home and away switch working.. but how to disable/enable a timer within a scene from another switch...

RayAmsterdam
Posts: 190
Joined: Sunday 11 January 2015 17:40
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Hoe to disable/enable a timer in a scene from another ??

Post by RayAmsterdam » Tuesday 04 August 2015 22:59

Why not use a the timer on a virtual switch and use this switch in your blockly to run the scenes?

User avatar
mrf68
Posts: 262
Joined: Monday 23 February 2015 13:45
Target OS: Windows
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: Hoe to disable/enable a timer in a scene from another ??

Post by mrf68 » Wednesday 05 August 2015 9:53

The manual shows how to "add a timer to a scene" using json. https://www.domoticz.com/wiki/Domoticz_ ... .2F_Groups
You could use this in combination with your home/away switch. When you're home, you set the timer being "true" and when you're away you set it to "false". I haven't tested this, but I'm just thinking out loud.
----------
3x RPi
1x W2k12 (vm)
3x RFXcom433e
1x Razberry board
KAKU: 9x APA3-1500R, 2x ACDB-7000C, 3x AMST-606, 1x APIR-2150, 1x AWS-3500, 1x ATMT-502
Z-wave: 8x Everspring AN145
Misc: 2x wireless doorbells

cyberbob
Posts: 33
Joined: Monday 02 March 2015 15:46
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Hoe to disable/enable a timer in a scene from another ??

Post by cyberbob » Saturday 08 August 2015 3:42

RayAmsterdam wrote:Why not use a the timer on a virtual switch and use this switch in your blockly to run the scenes?
cause the scene allows me easier access to 30 minutes before sunset instead of @ sunset.

cyberbob
Posts: 33
Joined: Monday 02 March 2015 15:46
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Hoe to disable/enable a timer in a scene from another ??

Post by cyberbob » Saturday 08 August 2015 3:43

mrf68 wrote:The manual shows how to "add a timer to a scene" using json. https://www.domoticz.com/wiki/Domoticz_ ... .2F_Groups
You could use this in combination with your home/away switch. When you're home, you set the timer being "true" and when you're away you set it to "false". I haven't tested this, but I'm just thinking out loud.

Nice thanks, ill try this one this weekend; This can work in more than 1 way :)

gjdv
Posts: 4
Joined: Wednesday 25 November 2015 21:16
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Hoe to disable/enable a timer in a scene from another ??

Post by gjdv » Monday 22 February 2016 13:58

I stumbled upon this thread when searching for a solution of the problem described. By browsing through the sourcecode, I found this simple solution of doing json calls to enable/disable the scenetimer (where you simply provide the scenetimer identifier which you can find e.g., by checking the action linked to the 'update' button after selecting the scenetimer in the domoticz gui (it says javascript:UpdateTimer(<scenetimeridx>)):
http://server:port/json.htm?type=command&param=enablescenetimer&idx=scenetimeridx
http://server:port/json.htm?type=command&param=disablescenetimer&idx=scenetimeridx
This can be done via any script that can be called on the appropriate event.
It's not listed on https://www.domoticz.com/wiki/Domoticz_ ... of_a_scene, but does work like a charm.

Number8
Posts: 285
Joined: Friday 23 May 2014 7:55
Target OS: Raspberry Pi
Domoticz version: 3.5103
Location: Saint Pierre de Jards
Contact:

Re: Hoe to disable/enable a timer in a scene from another ??

Post by Number8 » Sunday 06 March 2016 22:18

For the "regular timers" I use this command is a bash script that works as well

Code: Select all

curl --silent $IPADDRESS:$PORT'/json.htm?type=command&param=enabletimer&idx=idxvalue' > /dev/null

bluepi
Posts: 33
Joined: Tuesday 27 October 2015 22:37
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Hoe to disable/enable a timer in a scene from another ??

Post by bluepi » Monday 07 March 2016 10:18

You could use a variable as part of a script to check if home = true or false

Ouate
Posts: 23
Joined: Thursday 03 August 2017 15:44
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Hoe to disable/enable a timer in a scene from another ??

Post by Ouate » Sunday 17 September 2017 15:46

Hi,
does someone know how to disable/enable ALL times of a scene/group in the same time ?
With the index of the scene.
I am able to disable/enable a timer from a scene but I want to disable/enable all in the same time with only one http command. (to write in a NFC tag)

Is it possible?
thanks.

User avatar
philchillbill
Posts: 176
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: Hoe to disable/enable a timer in a scene from another ??

Post by philchillbill » Monday 18 September 2017 0:07

I use the following perl script which is run when the virtual home/away dummy switch is set, using the script://timers.pl construct. It bulk enables/disables all the timers it finds (except those on an ignore list) but you might be able to modify it to just do the idx'es in your scene:

Code: Select all

#!/usr/bin/perl
use JSON::XS;
use LWP::UserAgent;
no warnings 'uninitialized';

# Queries timers within Domoticz and bulk-enables/disables them depending on whether 0 or 1 is passed when executing
# Any idx values in the hash '%ignore' are skipped. If $debug is set to 1 the script provides feedback when run from command line 

$what=$ARGV[0];
unless (defined ($what)) { print "No parameter supplied, exiting. ($what)\n"; sleep 2; exit 0 };
if ($what == 1) { $action = 'enabletimer' } else { $action = 'disabletimer' };

$debug=0;
 
# get the list of scheduled timers into a hash
$domo_url='http://192.168.178.12:8080';
$ua=LWP::UserAgent->new; $ua->timeout(5);
$scheds=$domo_url.'/json.htm?type=schedules';
$response=$ua->get($scheds);
unless ($response->is_success) { warn "Error getting schedule data from Domoticz $response->status_line" };
$schedules=$response->decoded_content;
$jdata=decode_json $schedules;

%ignore = ( '38' => 1, '39' => 1 );

# loop through the timers and enable/disable them. Only idx is strictly needed, the others are for feedback
foreach $entry (@{$$jdata{result}}) {
 $name=$$entry{DevName};
 $time=$$entry{Time};
 $type=$$entry{TimerTypeStr};
 $idx=$$entry{TimerID}; 
 $cmd=$$entry{TimerCmd};  
 
 if ($ignore{$idx}) { next };

 $c++; $c=sprintf("%02d", $c);
 print "\[$c\] $name -- $type -- $time -- $cmd -- idx: $idx\n" if ($debug);
 $set_schedule=$domo_url."/json.htm?type=command&param=$action&idx=$idx";
 $response=$ua->get($set_schedule);
 unless ($response->is_success) { warn "Error performing '$action' $response->status_line" };

NUC/Ubuntu, Evohome Heating + HGI80, Evohome Security, 4x HikVision IP cams, Aeotec, Neo & Fibaro Z-Wave, Logitech Media Server (on Synology DS916+), 10x SqueezeBox, Kodi, Harmony Hub, 5x Amazon Echo, HA-Bridge, Hue.

Ouate
Posts: 23
Joined: Thursday 03 August 2017 15:44
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Hoe to disable/enable a timer in a scene from another ??

Post by Ouate » Monday 18 September 2017 9:33

thank you philchillbill :)
I will try your script later

gemminiss
Posts: 2
Joined: Tuesday 06 March 2018 17:33
Target OS: Windows
Domoticz version:
Contact:

Re: Hoe to disable/enable a timer in a scene from another ??

Post by gemminiss » Thursday 05 July 2018 12:06

SOLVED

hello everyone.

I'll would like to share with you have I solved in my system (Raspbian+domoticz v4.97).

I have very low programmings skills, so probably I'm missing something, so all comments are welcomed :)

Before start playing with physical devices, I tried with Virtual devices for testing:
  • I've created 2 dummy switches, and 1 Scene and 1 Blockly Event.
  • For the trigger, I've created a dummy switch called: Fuera de Casa (Out of home)
  • The device to be controlled by the scene: I've created a second dummy switch called: Deteccion Jardin (Garden's Detector)
  • I've created a scene called: test, I have added the device/swicth 'Deteccion Jardin', and I've added a Timmer: type 'On' & 'On time' & 'everyday'. For the time, in order to see if the script works, I've just taken the current time and I've added +4 minutes.
  • Then I have added the witches and scene in the Dashboard to see better the interaction between them.
  • Finally I did à simple Blockly script which I named it Test, and i said:
Image

After a couple of tests, it worked!!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests