Skip to content

Instantly share code, notes, and snippets.

@marcmerlin
Created December 30, 2014 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcmerlin/8b42499b3000cff0aab1 to your computer and use it in GitHub Desktop.
Save marcmerlin/8b42499b3000cff0aab1 to your computer and use it in GitHub Desktop.
Voice command, on with off on timer
Call the voice command defined below like so:
run_voice_cmd "Open lvr blind" if ($lvr_blind_x10r->state_now eq ON);
# noloop=start
my $lvr_blind_off_timer = new Timer();
$lvr_blind->set("off");
# noloop=stop
$lvr_blind->set("off") if ($lvr_blind_off_timer->expired);
my $v_open_lvr_blind = new Voice_Cmd("Open lvr blind");
if ($v_open_lvr_blind->said)
{
if (not $Save{lvr_blind_open} and $lvr_blind_off_timer->inactive)
{
print_log("BLIND: Open lvr_blind");
$lvr_blind_off_timer->set(3);
$Save{lvr_blind_open} = 1;
}
else
{
print_log("lvr blind already opened");
}
} elsif ($v_close_lvr_blind->said) {
if ($Save{lvr_blind_open} and $lvr_blind_off_timer->inactive)
{
print_log("BLIND: Close lvr_blind");
$lvr_blind_off_timer->set(3);
$Save{lvr_blind_open} = 0;
}
else
{
print_log("lvr blind already closed");
}
} elsif ($v_toggle_lvr_blind->said) {
# If we get off sync bright/dim toggles to reset state.
if ($lvr_blind_off_timer->inactive)
{
print_log("BLIND: Toggle lvr_blind");
$lvr_blind_off_timer->set(3);
}
else
{
print_log("Got toggle for lvr_blind but timer set to ".$lvr_blind_off_timer->query.", skipping");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment