-
Notifications
You must be signed in to change notification settings - Fork 131
SequenceEvents
You can set MH to do a sequence of events from one command as follows.
For example when one command is received (ie. Testlight ON) it will turn lamp module D1 off for 1 second, then ON for 20 minutes, dim to 60% for one minute, then off.
You have an X10 switch addressed A1 code my $watch_A1 = new X10_Item("A1"); my $control_D1 = new X10_Item("D1");
if (state_now $watch_A1 eq ON) {
# First, turn OFF for 1 second and then ON $control_D1->set_with_timer(OFF, 1, ON);
# Next, schedule a timer to run in 20 minutes. When it runs, turn light to 60% and then turn it OFF 60 seconds later my $dim_timer = new Timer();
set $dim_timer 20*60, '$control_D1->set_with_timer("60%", 60, OFF)';
} code You can also stack the states with delays all in one go, like this: code $watch_A1 = new X10_Item("A1"); $control_D1 = new X10_Item("D1");
set $control_D1 'OFF~1~ON~20~60%~60~OFF' if state_now $watch_A1; code
if you just want a sequence without the delays use : so you might have 'on~1~off:on:off:on:off' but the device might not be able to handle data this quick.
- Notes:**
- set_with_timer only does two events.
- It works for X10 devices but not serial.
- Because some code uses ~ eg in file abbreviation thus C:\progr~1\winamp.exe and elsewhere the timer feature is disabled in some Items from version 2.80. However it can be reactivated.
To fix this, add this elseif clause in lib/Generic_Item.pm: code sub state_overload {
my ($self, $flag) = @_; if (lc $flag eq 'off') { $self->{states_nomultistate} = 1; $self->{states_nosubstate} = 1; } elsif (lc $flag eq 'on') { $self->{states_nomultistate} = 0; $self->{states_nosubstate} = 0; }
} code