diff --git a/fhem/CHANGED b/fhem/CHANGED index 49670a385..e047973f5 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_BD: new attribute "disable" to disable cyclic status + updates of player - change: 09_CUL_FHTTK.pm: added event-on...readings and event-min-interval updated to reading update mechanism - feature: Dashboard: Groupstitel now can show icons, diff --git a/fhem/FHEM/71_YAMAHA_BD.pm b/fhem/FHEM/71_YAMAHA_BD.pm index 02d82562d..076d2faa9 100755 --- a/fhem/FHEM/71_YAMAHA_BD.pm +++ b/fhem/FHEM/71_YAMAHA_BD.pm @@ -37,6 +37,7 @@ use HttpUtils; sub YAMAHA_BD_Get($@); sub YAMAHA_BD_Define($$); sub YAMAHA_BD_GetStatus($;$); +sub YAMAHA_BD_Attr(@); sub YAMAHA_BD_ResetTimer($;$); sub YAMAHA_BD_Undefine($$); @@ -52,9 +53,10 @@ YAMAHA_BD_Initialize($) $hash->{GetFn} = "YAMAHA_BD_Get"; $hash->{SetFn} = "YAMAHA_BD_Set"; $hash->{DefFn} = "YAMAHA_BD_Define"; + $hash->{AttrFn} = "YAMAHA_BD_Attr"; $hash->{UndefFn} = "YAMAHA_BD_Undefine"; - $hash->{AttrList} = "do_not_notify:0,1 request-timeout:1,2,3,4,5 model ". + $hash->{AttrList} = "do_not_notify:0,1 disable:0,1 request-timeout:1,2,3,4,5 model ". $readingFnAttributes; } @@ -524,11 +526,55 @@ YAMAHA_BD_Define($$) } # start the status update timer + $hash->{helper}{DISABLED} = 0 unless(exists($hash->{helper}{DISABLED})); YAMAHA_BD_ResetTimer($hash, 2); return undef; } +########################## +sub +YAMAHA_BD_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_BD_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_BD_GetStatus($hash, 1); + } + + # Start/Stop Timer according to new disabled-Value + YAMAHA_BD_ResetTimer($hash); + + return undef; +} + +############################# +sub +YAMAHA_BD_Undefine($$) +{ + my($hash, $name) = @_; + + # Stop the internal GetStatus-Loop and exit + RemoveInternalTimer($hash); + return undef; +} + + ############################################################################################################# # # Begin of helper functions @@ -588,32 +634,24 @@ YAMAHA_BD_ResetTimer($;$) RemoveInternalTimer($hash); - if(defined($interval)) + if($hash->{helper}{DISABLED} == 0) { - InternalTimer(gettimeofday()+$interval, "YAMAHA_BD_GetStatus", $hash, 0); + if(defined($interval)) + { + InternalTimer(gettimeofday()+$interval, "YAMAHA_BD_GetStatus", $hash, 0); + } + elsif($hash->{READINGS}{presence}{VAL} eq "present" and $hash->{READINGS}{power}{VAL} eq "on") + { + InternalTimer(gettimeofday()+$hash->{helper}{ON_INTERVAL}, "YAMAHA_BD_GetStatus", $hash, 0); + } + else + { + InternalTimer(gettimeofday()+$hash->{helper}{OFF_INTERVAL}, "YAMAHA_BD_GetStatus", $hash, 0); + } } - elsif($hash->{READINGS}{presence}{VAL} eq "present" and $hash->{READINGS}{power}{VAL} eq "on") - { - InternalTimer(gettimeofday()+$hash->{helper}{ON_INTERVAL}, "YAMAHA_BD_GetStatus", $hash, 0); - } - else - { - InternalTimer(gettimeofday()+$hash->{helper}{OFF_INTERVAL}, "YAMAHA_BD_GetStatus", $hash, 0); - } - } -############################# -sub -YAMAHA_BD_Undefine($$) -{ - my($hash, $name) = @_; - - # Stop the internal GetStatus-Loop and exit - RemoveInternalTimer($hash); - return undef; -} ############################# @@ -795,11 +833,14 @@ sub YAMAHA_BD_formatTimestamp($)