From 1d49bfa2c6bf3cd830e310fb8d1f82dff1b503bb Mon Sep 17 00:00:00 2001 From: markusbloch <> Date: Mon, 17 Feb 2014 17:30:21 +0000 Subject: [PATCH] YAMAHA_AVR: new attribute "disable" to disable cyclic status updates of receiver git-svn-id: https://svn.fhem.de/fhem/trunk@4965 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 2 + fhem/FHEM/71_YAMAHA_AVR.pm | 91 +++++++++++++++++++++++++++++--------- 2 files changed, 71 insertions(+), 22 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 71410406c..91d37e3fb 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,6 +1,8 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. - SVN + - feature: YAMAHA_AVR: new attribute "disable" to disable cyclic status + updates of receiver - feature: LightScene: added attribute switchingOrder - added: new module 00_THZ.pm (immiimmi) - added: new module 98_HTTPMOD.pm (stefanstrobel) diff --git a/fhem/FHEM/71_YAMAHA_AVR.pm b/fhem/FHEM/71_YAMAHA_AVR.pm index 84294dff3..2ccacc53f 100755 --- a/fhem/FHEM/71_YAMAHA_AVR.pm +++ b/fhem/FHEM/71_YAMAHA_AVR.pm @@ -37,6 +37,7 @@ use HttpUtils; sub YAMAHA_AVR_Get($@); sub YAMAHA_AVR_Define($$); sub YAMAHA_AVR_GetStatus($;$); +sub YAMAHA_AVR_Attr(@); sub YAMAHA_AVR_ResetTimer($;$); sub YAMAHA_AVR_Undefine($$); @@ -52,9 +53,10 @@ YAMAHA_AVR_Initialize($) $hash->{GetFn} = "YAMAHA_AVR_Get"; $hash->{SetFn} = "YAMAHA_AVR_Set"; $hash->{DefFn} = "YAMAHA_AVR_Define"; + $hash->{AttrFn} = "YAMAHA_AVR_Attr"; $hash->{UndefFn} = "YAMAHA_AVR_Undefine"; - $hash->{AttrList} = "do_not_notify:0,1 request-timeout:1,2,3,4,5 volumeSteps:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 model volume-smooth-change:0,1 volume-smooth-steps:1,2,3,4,5,6,7,8,9,10 ". + $hash->{AttrList} = "do_not_notify:0,1 disable:0,1 request-timeout:1,2,3,4,5 volumeSteps:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 model volume-smooth-change:0,1 volume-smooth-steps:1,2,3,4,5,6,7,8,9,10 ". $readingFnAttributes; } @@ -674,11 +676,56 @@ YAMAHA_AVR_Define($$) } # start the status update timer + $hash->{helper}{DISABLED} = 0 unless(exists($hash->{helper}{DISABLED})); YAMAHA_AVR_ResetTimer($hash,2); return undef; } + +########################## +sub +YAMAHA_AVR_Attr(@) +{ + my @a = @_; + my $hash = $defs{$a[1]}; + + if($a[0] eq "set" && $a[2] eq "disable") + { + if($a[3] eq "0") + { + $hash->{helper}{DISABLED} = 0; + YAMAHA_AVR_GetStatus($hash, 1); + } + elsif($a[3] eq "1") + { + $hash->{helper}{DISABLED} = 1; + } + } + elsif($a[0] eq "del" && $a[2] eq "disable") + { + $hash->{helper}{DISABLED} = 0; + YAMAHA_AVR_GetStatus($hash, 1); + } + + # Start/Stop Timer according to new disabled-Value + YAMAHA_AVR_ResetTimer($hash); + + return undef; +} + +############################# +sub +YAMAHA_AVR_Undefine($$) +{ + my($hash, $name) = @_; + + # Stop the internal GetStatus-Loop and exit + RemoveInternalTimer($hash); + return undef; +} + + ############################################################################################################# # # Begin of helper functions @@ -734,16 +781,6 @@ YAMAHA_AVR_SendCommand($$;$) } -############################# -sub -YAMAHA_AVR_Undefine($$) -{ - my($hash, $name) = @_; - - # Stop the internal GetStatus-Loop and exit - RemoveInternalTimer($hash); - return undef; -} ############################# @@ -1023,19 +1060,21 @@ sub YAMAHA_AVR_ResetTimer($;$) RemoveInternalTimer($hash); - if(defined($interval)) + if($hash->{helper}{DISABLED} == 0) { - InternalTimer(gettimeofday()+$interval, "YAMAHA_AVR_GetStatus", $hash, 0); + if(defined($interval)) + { + InternalTimer(gettimeofday()+$interval, "YAMAHA_AVR_GetStatus", $hash, 0); + } + elsif((exists($hash->{READINGS}{presence}{VAL}) and $hash->{READINGS}{presence}{VAL} eq "present") and (exists($hash->{READINGS}{power}{VAL}) and $hash->{READINGS}{power}{VAL} eq "on")) + { + InternalTimer(gettimeofday()+$hash->{helper}{ON_INTERVAL}, "YAMAHA_AVR_GetStatus", $hash, 0); + } + else + { + InternalTimer(gettimeofday()+$hash->{helper}{OFF_INTERVAL}, "YAMAHA_AVR_GetStatus", $hash, 0); + } } - elsif((exists($hash->{READINGS}{presence}{VAL}) and $hash->{READINGS}{presence}{VAL} eq "present") and (exists($hash->{READINGS}{power}{VAL}) and $hash->{READINGS}{power}{VAL} eq "on")) - { - InternalTimer(gettimeofday()+$hash->{helper}{ON_INTERVAL}, "YAMAHA_AVR_GetStatus", $hash, 0); - } - else - { - InternalTimer(gettimeofday()+$hash->{helper}{OFF_INTERVAL}, "YAMAHA_AVR_GetStatus", $hash, 0); - } - } sub YAMAHA_AVR_html2txt($) @@ -1236,6 +1275,10 @@ sub YAMAHA_AVR_html2txt($) Optional attribute change the response timeout in seconds for all queries to the receiver.

Possible values: 1-5 seconds. Default value is 4 seconds.

+
  • disable
  • + Optional attribute to disable the internal cyclic status update of the receiver. Manual status updates via statusRequest command is still possible. +

    + Possible values: 0 => perform cyclic status update, 1 => don't perform cyclic status updates.

  • volume-smooth-change
  • Optional attribute to activate a smooth volume change.

    @@ -1441,6 +1484,10 @@ sub YAMAHA_AVR_html2txt($) Optionales Attribut. Maximale Dauer einer Anfrage in Sekunden zum Receiver.

    Mögliche Werte: 1-5 Sekunden. Standardwert ist 4 Sekunden

    +
  • disable
  • + Optionales Attribut zur Deaktivierung des zyklischen Status-Updates. Ein manuelles Update via statusRequest-Befehl ist dennoch möglich. +

    + Mögliche Werte: 0 => zyklische Status-Updates, 1 => keine zyklischen Status-Updates.

  • volume-smooth-change
  • Optionales Attribut, welches einen weichen Lautstärkeübergang aktiviert..