From 66ba47c455f6dba12a14afb9162621f4f51de769 Mon Sep 17 00:00:00 2001 From: Beta-User <> Date: Fri, 2 Dec 2022 07:28:04 +0000 Subject: [PATCH] 71_YAMAHA_AVR: PBP review part 1 - remove prototypes git-svn-id: https://svn.fhem.de/fhem/trunk@26762 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/71_YAMAHA_AVR.pm | 306 +++++++++++++++++++------------------ 2 files changed, 155 insertions(+), 152 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 36dfbdcbf..392d9abd6 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # 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. + - change: 71_YAMAHA_AVR: PBP code restructured (part I) - change: 93_DbLog: revise commandref - bugfix: 98_vitoconnect: Missing update interval after login failure - bugfix: 73_km200 : Forward declaration made obsolete diff --git a/fhem/FHEM/71_YAMAHA_AVR.pm b/fhem/FHEM/71_YAMAHA_AVR.pm index 2d7e8c74c..263ba328e 100755 --- a/fhem/FHEM/71_YAMAHA_AVR.pm +++ b/fhem/FHEM/71_YAMAHA_AVR.pm @@ -33,25 +33,18 @@ use warnings; use Time::HiRes qw(gettimeofday sleep); use Encode qw(decode encode); 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($$); ################################### sub -YAMAHA_AVR_Initialize($) +YAMAHA_AVR_Initialize { - my ($hash) = @_; + my $hash = shift; - $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->{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 ". "disable:0,1 ". @@ -68,50 +61,52 @@ YAMAHA_AVR_Initialize($) "volume-smooth-change" => "volumeSmoothChange", "volume-smooth-steps" => "volumeSmoothSteps" }; + return; } ############################# sub -YAMAHA_AVR_Define($$) +YAMAHA_AVR_Define { - my ($hash, $def) = @_; - my @a = split("[ \t][ \t]*", $def); - my $name = $hash->{NAME}; - - if(!@a >= 4) + my $hash = shift // return; + my $def = shift // return; + my @arr = split m{\s+}xms, $def; + my $name = shift @arr; + + if(@arr < 2) { - my $msg = "wrong syntax: define YAMAHA_AVR [] [] [] "; - Log3 $name, 2, $msg; + my $msg = 'wrong syntax: define YAMAHA_AVR [] [] [] '; + Log3($name, 2, $msg); return $msg; } - my $address = $a[2]; + my $address = $arr[1]; $hash->{helper}{ADDRESS} = $address; # if a zone was given, use it, otherwise use the mainzone - if(defined($a[3])) + if(defined($arr[2])) { - $hash->{helper}{SELECTED_ZONE} = $a[3]; + $hash->{helper}{SELECTED_ZONE} = $arr[2]; } else { - $hash->{helper}{SELECTED_ZONE} = "mainzone"; + $hash->{helper}{SELECTED_ZONE} = 'mainzone'; } # if an update interval was given which is greater than zero, use it. - if(defined($a[4]) and $a[4] > 0) + if ( defined $arr[3] && $arr[3] > 0 ) { - $hash->{helper}{OFF_INTERVAL} = $a[4]; + $hash->{helper}{OFF_INTERVAL} = $arr[3]; } else { $hash->{helper}{OFF_INTERVAL} = 30; } - if(defined($a[5]) and $a[5] > 0) + if ( defined $arr[4] && $arr[4] > 0 ) { - $hash->{helper}{ON_INTERVAL} = $a[5]; + $hash->{helper}{ON_INTERVAL} = $arr[4]; } else { @@ -119,12 +114,12 @@ YAMAHA_AVR_Define($$) } $hash->{helper}{CMD_QUEUE} = []; - delete($hash->{helper}{".HTTP_CONNECTION"}) if(exists($hash->{helper}{".HTTP_CONNECTION"})); + delete $hash->{helper}{".HTTP_CONNECTION"} if exists $hash->{helper}{".HTTP_CONNECTION"}; # In case of a redefine, check the zone parameter if the specified zone exist, otherwise use the main zone - if(defined($hash->{helper}{ZONES}) and length($hash->{helper}{ZONES}) > 0) + if ( defined $hash->{helper}{ZONES} && length $hash->{helper}{ZONES} > 0 ) { - if(defined(YAMAHA_AVR_getParamName($hash, lc $hash->{helper}{SELECTED_ZONE}, $hash->{helper}{ZONES}))) + if ( defined YAMAHA_AVR_getParamName($hash, lc $hash->{helper}{SELECTED_ZONE}, $hash->{helper}{ZONES}) ) { $hash->{ACTIVE_ZONE} = lc $hash->{helper}{SELECTED_ZONE}; } @@ -145,59 +140,60 @@ YAMAHA_AVR_Define($$) # start the status update timer YAMAHA_AVR_ResetTimer($hash,1); - return undef; + return; } ################################### sub -YAMAHA_AVR_GetStatus($;$) +YAMAHA_AVR_GetStatus #($;$) { - my ($hash, $local) = @_; + my $hash = shift // return; + my $local = shift // 0; my $name = $hash->{NAME}; my $power; - $local = 0 unless(defined($local)); + #$local = 0 unless(defined($local)); - return "" if(!defined($hash->{helper}{ADDRESS}) or !defined($hash->{helper}{OFF_INTERVAL}) or !defined($hash->{helper}{ON_INTERVAL})); + return '' if !defined $hash->{helper}{ADDRESS} || !defined $hash->{helper}{OFF_INTERVAL} || !defined $hash->{helper}{ON_INTERVAL}; my $device = $hash->{helper}{ADDRESS}; # get the model informations and available zones if no informations are available - if(not defined($hash->{ACTIVE_ZONE}) or not defined($hash->{helper}{ZONES}) or not defined($hash->{MODEL}) or not defined($hash->{FIRMWARE})) + if ( !defined $hash->{ACTIVE_ZONE} || !defined $hash->{helper}{ZONES} || !defined$hash->{MODEL} || !defined $hash->{FIRMWARE} ) { YAMAHA_AVR_getModel($hash); } # get all available inputs and scenes if nothing is available - if((not defined($hash->{helper}{INPUTS}) or length($hash->{helper}{INPUTS}) == 0)) + if( !defined($hash->{helper}{INPUTS}) || length $hash->{helper}{INPUTS} == 0 ) { YAMAHA_AVR_getInputs($hash); } my $zone = YAMAHA_AVR_getParamName($hash, $hash->{ACTIVE_ZONE}, $hash->{helper}{ZONES}); - if(not defined($zone)) + if ( !defined $zone ) { - YAMAHA_AVR_ResetTimer($hash) unless($local == 1); - return "No Zone available"; + YAMAHA_AVR_ResetTimer($hash) if $local != 1; + return 'No Zone available'; } YAMAHA_AVR_SendCommand($hash, "<$zone>GetParam", "statusRequest", "basicStatus"); - if($hash->{ACTIVE_ZONE} eq "mainzone" and (!exists($hash->{helper}{SUPPORT_PARTY_MODE}) or $hash->{helper}{SUPPORT_PARTY_MODE})) + if ( $hash->{ACTIVE_ZONE} eq 'mainzone' && ( !exists $hash->{helper}{SUPPORT_PARTY_MODE} || $hash->{helper}{SUPPORT_PARTY_MODE} ) ) { YAMAHA_AVR_SendCommand($hash, "GetParam", "statusRequest", "partyModeStatus", {options => {can_fail => 1}}); } - elsif($hash->{ACTIVE_ZONE} ne "mainzone" and (!exists($hash->{helper}{SUPPORT_PARTY_MODE}) or $hash->{helper}{SUPPORT_PARTY_MODE})) + elsif ( $hash->{ACTIVE_ZONE} ne 'mainzone' && ( !exists $hash->{helper}{SUPPORT_PARTY_MODE} || $hash->{helper}{SUPPORT_PARTY_MODE} ) ) { YAMAHA_AVR_SendCommand($hash, "GetParam", "statusRequest", "partyModeZones", {options => {can_fail => 1}}); } - - if($hash->{ACTIVE_ZONE} eq "mainzone" and (!exists($hash->{helper}{SUPPORT_SURROUND_DECODER}) or $hash->{helper}{SUPPORT_SURROUND_DECODER})) + + if ( $hash->{ACTIVE_ZONE} eq 'mainzone' && ( !exists $hash->{helper}{SUPPORT_SURROUND_DECODER} || $hash->{helper}{SUPPORT_SURROUND_DECODER} ) ) { YAMAHA_AVR_SendCommand($hash, "<$zone>GetParam", "statusRequest", "surroundDecoder", {options => {can_fail => 1}}); } - + if($hash->{ACTIVE_ZONE} eq "mainzone" and (!exists($hash->{helper}{SUPPORT_DISPLAY_BRIGHTNESS}) or $hash->{helper}{SUPPORT_DISPLAY_BRIGHTNESS})) { if(YAMAHA_AVR_isModel_DSP($hash)) @@ -209,7 +205,7 @@ YAMAHA_AVR_GetStatus($;$) YAMAHA_AVR_SendCommand($hash, "GetParam", "statusRequest", "displayBrightness", {options => {can_fail => 1}}); } } - + if(!exists($hash->{helper}{SUPPORT_TONE_STATUS}) or (exists($hash->{helper}{SUPPORT_TONE_STATUS}) and exists($hash->{MODEL}) and $hash->{helper}{SUPPORT_TONE_STATUS})) { if(YAMAHA_AVR_isModel_DSP($hash)) @@ -254,26 +250,24 @@ YAMAHA_AVR_GetStatus($;$) YAMAHA_AVR_ResetTimer($hash) unless($local == 1); - return undef; + return; } ################################### sub -YAMAHA_AVR_Get($@) +YAMAHA_AVR_Get #($@) { - my ($hash, @a) = @_; - my $what; - my $return; + my ($hash, @arr) = @_; + + return 'argument is missing' if @arr != 2; - return "argument is missing" if(int(@a) != 2); + my $what = $arr[1]; - $what = $a[1]; - - return ReadingsVal($hash->{NAME}, $what, "") if(defined(ReadingsVal($hash->{NAME}, $what, undef))); + return ReadingsVal($hash->{NAME}, $what, '') if defined ReadingsVal($hash->{NAME}, $what, undef); - $return = "unknown argument $what, choose one of"; + my $return = "unknown argument $what, choose one of"; - foreach my $reading (keys %{$hash->{READINGS}}) + for my $reading (keys %{$hash->{READINGS}}) { $return .= " $reading:noArg"; } @@ -284,7 +278,7 @@ YAMAHA_AVR_Get($@) ################################### sub -YAMAHA_AVR_Set($@) +YAMAHA_AVR_Set #($@) { my ($hash, @a) = @_; my $name = $hash->{NAME}; @@ -356,12 +350,12 @@ YAMAHA_AVR_Set($@) "statusRequest:noArg"; # number of seconds to wait after on/off was executed (DSP based: 3 sec, other models: 2 sec) - my $powerCmdDelay = (YAMAHA_AVR_isModel_DSP($hash) ? "3" : "2"); - + my $powerCmdDelay = YAMAHA_AVR_isModel_DSP($hash) ? 3 : 2; + Log3 $name, 5, "YAMAHA_AVR ($name) - set ".join(" ", @a); - + if($what eq "on") - { + { YAMAHA_AVR_SendCommand($hash, "<$zone>On" ,$what, undef, {options => {wait_after_response => $powerCmdDelay}}); } elsif($what eq "off") @@ -1139,20 +1133,19 @@ YAMAHA_AVR_Set($@) else { return $usage; - } + } + return; } ########################## sub -YAMAHA_AVR_Attr(@) +YAMAHA_AVR_Attr #(@) { my ($cmd, $name, $attr, $val) = @_; - my $hash = $defs{$name}; + my $hash = $defs{$name} // return; - return unless($hash); - - if($attr eq "disable") + if($attr eq 'disable') { # Start/Stop Timer according to new disabled-Value YAMAHA_AVR_ResetTimer($hash, 1); @@ -1178,16 +1171,16 @@ YAMAHA_AVR_Attr(@) } } } - - return undef; + return; } ############################# sub -YAMAHA_AVR_Undefine($$) +YAMAHA_AVR_Undefine #($$) { - my($hash, $name) = @_; + my $hash = shift // return; + my $name = shift // return; # Stop all timers and exit RemoveInternalTimer($hash); @@ -1197,7 +1190,7 @@ YAMAHA_AVR_Undefine($$) delete($modules{YAMAHA_AVR}{defptr}{$hash->{SYSTEM_ID}}{$hash->{ACTIVE_ZONE}}); } - return undef; + return; } @@ -1243,9 +1236,14 @@ YAMAHA_AVR_Undefine($$) ############################# # sends a command to the receiver via HTTP sub -YAMAHA_AVR_SendCommand($$$$;$) +YAMAHA_AVR_SendCommand #($$$$;$) { - my ($hash, $data,$cmd,$arg,$additional_args) = @_; + #my ($hash, $data,$cmd,$arg,$additional_args) = @_; + my $hash = shift // return; + my $data = shift // return; + my $cmd = shift // return; + my $arg = shift // return; + my $additional_args = shift; #if set, this should be HASH type arg my $name = $hash->{NAME}; my $options; @@ -1300,18 +1298,17 @@ YAMAHA_AVR_SendCommand($$$$;$) push @{$device->{helper}{CMD_QUEUE}}, $param; } } - + YAMAHA_AVR_HandleCmdQueue($device); - - return undef; + return; } ############################# # starts http requests from cmd queue sub -YAMAHA_AVR_HandleCmdQueue($) +YAMAHA_AVR_HandleCmdQueue #($) { - my ($hash) = @_; + my $hash = shift // return; my $name = $hash->{NAME}; my $address = $hash->{helper}{ADDRESS}; @@ -1331,16 +1328,16 @@ YAMAHA_AVR_HandleCmdQueue($) my $request = YAMAHA_AVR_getNextRequestHash($hash); - unless(defined($request)) + if ( !defined $request ) { # still request in queue, but not mentioned to be executed now Log3 $name, 5, "YAMAHA_AVR ($name) - still requests in queue, but no command shall be executed at the moment. Retry in 1 second."; RemoveInternalTimer($hash, "YAMAHA_AVR_HandleCmdQueue"); InternalTimer(gettimeofday()+1,"YAMAHA_AVR_HandleCmdQueue", $hash); - return undef; + return; } - $request->{options}{priority} = 3 unless(exists($request->{options}{priority})); + $request->{options}{priority} = 3 if !exists $request->{options}{priority}; delete($request->{data}) if(exists($request->{data}) and !$request->{data}); $request->{data}=~ s/\[CURRENT_INPUT_TAG\]/$hash->{helper}{CURRENT_INPUT_TAG}/g if(exists($request->{data}) and exists($hash->{helper}{CURRENT_INPUT_TAG})); @@ -1367,14 +1364,14 @@ YAMAHA_AVR_HandleCmdQueue($) $hash->{CMDs_pending} = @{$hash->{helper}{CMD_QUEUE}}; delete($hash->{CMDs_pending}) unless($hash->{CMDs_pending}); - return undef; + return; } ############################# # selects the next command from command queue that has to be executed (undef if no command has to be executed now) -sub YAMAHA_AVR_getNextRequestHash($) +sub YAMAHA_AVR_getNextRequestHash #($) { - my ($hash) = @_; + my $hash = shift // return; my $name = $hash->{NAME}; if(@{$hash->{helper}{CMD_QUEUE}}) @@ -1451,17 +1448,19 @@ sub YAMAHA_AVR_getNextRequestHash($) } Log3 $name, 5, "YAMAHA_AVR ($name) - no suitable command item found"; - return undef; + return; } } ############################# # parses the receiver response sub -YAMAHA_AVR_ParseResponse($$$) +YAMAHA_AVR_ParseResponse #($$$) { - my ( $param, $err, $data ) = @_; - + my $param = shift // return; + my $err = shift // q{}; + my $data = shift // q{}; + my $hash = $param->{hash}; my $queue_hash = $param->{hash}; @@ -1469,9 +1468,6 @@ YAMAHA_AVR_ParseResponse($$$) my $arg = $param->{arg}; my $options = $param->{options}; - $data = "" unless(defined($data)); - $err = "" unless(defined($err)); - $hash->{helper}{RUNNING_REQUEST} = 0; delete($hash->{helper}{".HTTP_CONNECTION"}) unless($param->{keepalive}); @@ -2130,7 +2126,7 @@ YAMAHA_AVR_ParseResponse($$$) Log3 $name, 4 ,"YAMAHA_AVR ($name) - menu browsing to $arg is finished. requesting basic status"; readingsEndUpdate($hash, 1); YAMAHA_AVR_GetStatus($hash, 1); - return undef; + return; } # initialization sequence @@ -2260,63 +2256,67 @@ YAMAHA_AVR_ParseResponse($$$) } YAMAHA_AVR_HandleCmdQueue($queue_hash); + return; } ############################# # Converts all Values to FHEM usable command lists -sub YAMAHA_AVR_Param2Fhem($$) +sub YAMAHA_AVR_Param2Fhem #($$) { - my ($param, $replace_pipes) = @_; + my $param = shift // return; + my $replace_pipes = shift; - $param =~ s/\s+//g; $param =~ s/,//g; $param =~ s/_//g; $param =~ s/\(/_/g; $param =~ s/\)//g; - $param =~ s/\|/,/g if($replace_pipes == 1); + $param =~ s/\|/,/g if $replace_pipes; return lc $param; } ############################# # Returns the Yamaha Parameter Name for the FHEM like aquivalents -sub YAMAHA_AVR_getParamName($$$) +sub YAMAHA_AVR_getParamName #($$$) { - my ($hash, $name, $list) = @_; - my $item; - - return undef if(not defined($list)); - + my $hash = shift // return; + my $name = shift // return; + my $list = shift // return; + my @commands = split("\\|", $list); - foreach $item (@commands) + for my $item (@commands) { if(YAMAHA_AVR_Param2Fhem($item, 0) eq $name) { return $item; } } - - return undef; + + return; } ############################# # queries the receiver model, system-id, version and all available zones -sub YAMAHA_AVR_getModel($) +sub YAMAHA_AVR_getModel #($) { - my ($hash) = @_; - + my $hash = shift // return; + YAMAHA_AVR_SendCommand($hash, "GetParam", "statusRequest","systemConfig", {options => {at_first => 1, priority => 1}}); YAMAHA_AVR_SendCommand($hash, "GetParam", "statusRequest","unitDescription", {options => {at_first => 1, priority => 1}}); -} - + + return; +} + ############################# # parses the HTTP response for unit description XML file sub -YAMAHA_AVR_ParseXML($$$) +YAMAHA_AVR_ParseXML #($$$) { - my ($param, $err, $data) = @_; + my $param = shift // return; + my $err = shift // return; + my $data = shift // return; my $hash = $param->{hash}; my $name = $hash->{NAME}; @@ -2326,10 +2326,10 @@ YAMAHA_AVR_ParseXML($$$) $hash->{helper}{RUNNING_REQUEST} = 0; delete($hash->{helper}{".HTTP_CONNECTION"}) unless($param->{keepalive}); - if($data eq "") + if($data eq '') { YAMAHA_AVR_HandleCmdQueue($hash); - return undef + return; } delete($hash->{helper}{ZONES}) if(exists($hash->{helper}{ZONES})); @@ -2459,14 +2459,15 @@ YAMAHA_AVR_ParseXML($$$) # create device pointer $modules{YAMAHA_AVR}{defptr}{$hash->{SYSTEM_ID}}{$hash->{ACTIVE_ZONE}} = $hash if(exists($hash->{SYSTEM_ID}) and exists($hash->{ACTIVE_ZONE})); - YAMAHA_AVR_HandleCmdQueue($hash); + YAMAHA_AVR_HandleCmdQueue($hash); + return; } ############################# # converts decibal volume in percentage volume (-80.5 .. 16.5dB => 0 .. 100%) -sub YAMAHA_AVR_volume_rel2abs($) +sub YAMAHA_AVR_volume_rel2abs #($) { - my ($percentage) = @_; + my $percentage = shift; # 0 - 100% -equals 80.5 to 16.5 dB return int((($percentage / 100 * 97) - 80.5) / 0.5) * 0.5; @@ -2474,9 +2475,9 @@ sub YAMAHA_AVR_volume_rel2abs($) ############################# # converts percentage volume in decibel volume (0 .. 100% => -80.5 .. 16.5dB) -sub YAMAHA_AVR_volume_abs2rel($) +sub YAMAHA_AVR_volume_abs2rel #($) { - my ($absolute) = @_; + my $absolute = shift // return; # -80.5 to 16.5 dB equals 0 - 100% return int(($absolute + 80.5) / 97 * 100); @@ -2484,56 +2485,56 @@ sub YAMAHA_AVR_volume_abs2rel($) ############################# # queries all available inputs and scenes -sub YAMAHA_AVR_getInputs($) +sub YAMAHA_AVR_getInputs #($) { - my ($hash) = @_; + my $hash = shift // return; my $name = $hash->{NAME}; my $address = $hash->{helper}{ADDRESS}; my $zone = YAMAHA_AVR_getParamName($hash, $hash->{ACTIVE_ZONE}, $hash->{helper}{ZONES}); - return undef if(not defined($zone) or $zone eq ""); + return if !defined $zone || $zone eq ''; # query all inputs YAMAHA_AVR_SendCommand($hash, "<$zone>GetParam", "statusRequest","getInputs", {options => {at_first => 1, priority => 1}}); # query all available scenes (only in mainzone available) - YAMAHA_AVR_SendCommand($hash, "<$zone>GetParam", "statusRequest","getScenes", {options => {can_fail => 1, at_first => 1, priority => 1}}) if($hash->{ACTIVE_ZONE} eq "mainzone"); + YAMAHA_AVR_SendCommand($hash, "<$zone>GetParam", "statusRequest","getScenes", {options => {can_fail => 1, at_first => 1, priority => 1}}) if $hash->{ACTIVE_ZONE} eq 'mainzone'; + return; } ############################# # Restarts the internal status request timer according to the given interval or current receiver state -sub YAMAHA_AVR_ResetTimer($;$) +sub YAMAHA_AVR_ResetTimer #($;$) { - my ($hash, $interval) = @_; + my $hash = shift // return; + my $interval = shift; my $name = $hash->{NAME}; RemoveInternalTimer($hash, "YAMAHA_AVR_GetStatus"); - unless(IsDisabled($name)) + return if IsDisabled($name); + if ( defined $interval ) { - if(defined($interval)) - { - InternalTimer(gettimeofday()+$interval, "YAMAHA_AVR_GetStatus", $hash); - } - elsif(ReadingsVal($name, "presence", "absent") eq "present" and ReadingsVal($name, "power", "off") eq "on") - { - InternalTimer(gettimeofday()+$hash->{helper}{ON_INTERVAL}, "YAMAHA_AVR_GetStatus", $hash); - } - else - { - InternalTimer(gettimeofday()+$hash->{helper}{OFF_INTERVAL}, "YAMAHA_AVR_GetStatus", $hash); - } + InternalTimer(gettimeofday()+$interval, "YAMAHA_AVR_GetStatus", $hash); } - - return undef; + elsif(ReadingsVal($name, "presence", "absent") eq "present" and ReadingsVal($name, "power", "off") eq "on") + { + InternalTimer(gettimeofday()+$hash->{helper}{ON_INTERVAL}, "YAMAHA_AVR_GetStatus", $hash); + } + else + { + InternalTimer(gettimeofday()+$hash->{helper}{OFF_INTERVAL}, "YAMAHA_AVR_GetStatus", $hash); + } + + return; } ############################# # convert all HTML entities into UTF-8 aquivalents -sub YAMAHA_AVR_html2txt($) +sub YAMAHA_AVR_html2txt #($) { - my ($string) = @_; + my $string = shift // return ''; $string =~ s/&/&/g; $string =~ s/&/&/g; @@ -2560,11 +2561,11 @@ sub YAMAHA_AVR_html2txt($) return $string; } -sub YAMAHA_AVR_generateSurroundDecoderList($) +sub YAMAHA_AVR_generateSurroundDecoderList #($) { - my ($hash) = @_; + my $hash = shift // return; - if(defined($hash->{MODEL})) + if ( defined $hash->{MODEL} ) { if($hash->{MODEL} =~ /^(?:RX-V[67]79|RX-A750|RX-AS710D?)$/) # RX-V679, RX-V779, RX-A750, RX-AS710, RX-AS710D (from RX-Vx79/RX-Ax50 series) { @@ -2583,15 +2584,16 @@ sub YAMAHA_AVR_generateSurroundDecoderList($) $hash->{helper}{SURROUND_DECODERS} = "Dolby PL|Dolby PLII Movie|Dolby PLII Music|Dolby PLII Game|Dolby PLIIx Movie|Dolby PLIIx Music|Dolby PLIIx Game|DTS NEO:6 Cinema|DTS NEO:6 Music"; } } + return; } ############################# # Check if amp is one of these models: DSP-Z7, DSP-Z9, DSP-Z11, RX-Z7, RX-Z9, RX-Z11, RX-V2065, RX-V3900, DSP-AX3900 # Tested models: DSP-Z7 -sub YAMAHA_AVR_isModel_DSP($) +sub YAMAHA_AVR_isModel_DSP #($) { - my($hash) = @_; + my $hash = shift // return; if(exists($hash->{MODEL}) && (($hash->{MODEL} =~ /DSP-Z/) || ($hash->{MODEL} =~ /RX-Z/) || ($hash->{MODEL} =~ /RX-V2065/) || ($hash->{MODEL} =~ /RX-V3900/) || ($hash->{MODEL} =~ /DSP-AX3900/))) {