YAMAHA_AVR: fixing module startup error; added additional log output

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@6324 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markusbloch 2014-07-28 15:04:33 +00:00
parent 0f0357aca0
commit ee1be560e2

View File

@ -75,7 +75,7 @@ YAMAHA_AVR_GetStatus($;$)
my $device = $hash->{helper}{ADDRESS}; my $device = $hash->{helper}{ADDRESS};
# get the model informations and available zones if no informations are available # 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}) or not defined($hash->{helper}{DSP_MODES})) if(not defined($hash->{ACTIVE_ZONE}) or not defined($hash->{helper}{ZONES}) or not defined($hash->{MODEL}) or not defined($hash->{FIRMWARE}))
{ {
YAMAHA_AVR_getModel($hash); YAMAHA_AVR_getModel($hash);
YAMAHA_AVR_ResetTimer($hash) unless($local == 1); YAMAHA_AVR_ResetTimer($hash) unless($local == 1);
@ -148,7 +148,7 @@ YAMAHA_AVR_Set($@)
my $address = $hash->{helper}{ADDRESS}; my $address = $hash->{helper}{ADDRESS};
# get the model informations and available zones if no informations are available # 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->{helper}{DSP_MODES}) or length($hash->{helper}{DSP_MODES}) == 0)) if(not defined($hash->{ACTIVE_ZONE}) or not defined($hash->{helper}{ZONES}))
{ {
YAMAHA_AVR_getModel($hash); YAMAHA_AVR_getModel($hash);
} }
@ -176,7 +176,7 @@ YAMAHA_AVR_Set($@)
my $what = $a[1]; my $what = $a[1];
my $usage = "Unknown argument $what, choose one of on:noArg off:noArg volumeStraight:slider,-80,1,16 volume:slider,0,1,100 volumeUp volumeDown ".(defined($hash->{helper}{INPUTS})?"input:".$inputs_comma." ":"")."mute:on,off,toggle remoteControl:setup,up,down,left,right,return,option,display,tunerPresetUp,tunerPresetDown,enter ".(defined($hash->{helper}{SCENES})?"scene:".$scenes_comma." ":"").($hash->{helper}{SELECTED_ZONE} eq "mainzone" ? "straight:on,off 3dCinemaDsp:off,auto adaptiveDrc:off,auto ".(exists($hash->{helper}{DIRECT_TAG}) ? "direct:on,off " : "").(exists($hash->{helper}{DSP_MODES}) ? "dsp:".$dsp_modes_comma." " : "")." enhancer:on,off " : "")."sleep:off,30min,60min,90min,120min,last statusRequest:noArg"; my $usage = "Unknown argument $what, choose one of on:noArg off:noArg volumeStraight:slider,-80,1,16 volume:slider,0,1,100 volumeUp volumeDown ".(defined($hash->{helper}{INPUTS})?"input:".$inputs_comma." ":"")."mute:on,off,toggle remoteControl:setup,up,down,left,right,return,option,display,tunerPresetUp,tunerPresetDown,enter ".(defined($hash->{helper}{SCENES})?"scene:".$scenes_comma." ":"").($hash->{helper}{SELECTED_ZONE} eq "mainzone" ? "straight:on,off 3dCinemaDsp:off,auto adaptiveDrc:off,auto ".(exists($hash->{helper}{DIRECT_TAG}) ? "direct:on,off " : "").(exists($hash->{helper}{DSP_MODES}) ? "dsp:".$dsp_modes_comma." " : "")." enhancer:on,off " : "")."sleep:off,30min,60min,90min,120min,last statusRequest:noArg";
Log3 $name, 5, "YAMAHA_AVR ($name) - ".join(" ", @a); Log3 $name, 5, "YAMAHA_AVR ($name) - set ".join(" ", @a);
if($what eq "on") if($what eq "on")
{ {
YAMAHA_AVR_SendCommand($hash, "<YAMAHA_AV cmd=\"PUT\"><$zone><Power_Control><Power>On</Power></Power_Control></$zone></YAMAHA_AV>" ,$what,undef); YAMAHA_AVR_SendCommand($hash, "<YAMAHA_AV cmd=\"PUT\"><$zone><Power_Control><Power>On</Power></Power_Control></$zone></YAMAHA_AV>" ,$what,undef);
@ -565,7 +565,11 @@ YAMAHA_AVR_Set($@)
return $usage; return $usage;
} }
} }
elsif($what ne "statusRequest") elsif($what eq "statusRequest")
{
YAMAHA_AVR_GetStatus($hash, 1);
}
else
{ {
return $usage; return $usage;
} }
@ -652,7 +656,7 @@ YAMAHA_AVR_Define($$)
# start the status update timer # start the status update timer
$hash->{helper}{DISABLED} = 0 unless(exists($hash->{helper}{DISABLED})); $hash->{helper}{DISABLED} = 0 unless(exists($hash->{helper}{DISABLED}));
YAMAHA_AVR_ResetTimer($hash,2); YAMAHA_AVR_ResetTimer($hash,0);
return undef; return undef;
} }
@ -865,8 +869,8 @@ YAMAHA_AVR_ParseResponse ($$$)
{ {
$hash->{helper}{INPUTS} .= "|"; $hash->{helper}{INPUTS} .= "|";
} }
Log3 $name, 4, "YAMAHA_AVR ($name) - found input: $1";
$hash->{helper}{INPUTS} .= $1; $hash->{helper}{INPUTS} .= $1;
} }
$hash->{helper}{INPUTS} = join("|", sort split("\\|", $hash->{helper}{INPUTS})); $hash->{helper}{INPUTS} = join("|", sort split("\\|", $hash->{helper}{INPUTS}));
@ -885,6 +889,7 @@ YAMAHA_AVR_ParseResponse ($$$)
{ {
$hash->{helper}{SCENES} .= "|"; $hash->{helper}{SCENES} .= "|";
} }
Log3 $name, 4, "YAMAHA_AVR ($name) - found scene: $1";
$hash->{helper}{SCENES} .= $1; $hash->{helper}{SCENES} .= $1;
} }
} }
@ -1222,13 +1227,15 @@ YAMAHA_AVR_ParseXML($$$)
delete($hash->{helper}{ZONES}) if(exists($hash->{helper}{ZONES})); delete($hash->{helper}{ZONES}) if(exists($hash->{helper}{ZONES}));
Log3 $name, 4, "YAMAHA_AVR ($name) - checking available zones";
while($data =~ /<Menu Func="Subunit" Title_1="(.+?)" YNC_Tag="(.+?)">/gc) while($data =~ /<Menu Func="Subunit" Title_1="(.+?)" YNC_Tag="(.+?)">/gc)
{ {
if(defined($hash->{helper}{ZONES}) and length($hash->{helper}{ZONES}) > 0) if(defined($hash->{helper}{ZONES}) and length($hash->{helper}{ZONES}) > 0)
{ {
$hash->{helper}{ZONES} .= "|"; $hash->{helper}{ZONES} .= "|";
} }
Log3 $name, 4, "YAMAHA_AVR ($name) - adding zone: $2";
$hash->{helper}{ZONES} .= $2; $hash->{helper}{ZONES} .= $2;
} }
@ -1239,18 +1246,23 @@ YAMAHA_AVR_ParseXML($$$)
{ {
my $modes = $1; my $modes = $1;
Log3 $name, 4, "YAMAHA_AVR ($name) - found DSP modes in XML";
while($modes =~ /<Direct.*?>(.+?)<\/Direct>/gc) while($modes =~ /<Direct.*?>(.+?)<\/Direct>/gc)
{ {
if(defined($hash->{helper}{DSP_MODES}) and length($hash->{helper}{DSP_MODES}) > 0) if(defined($hash->{helper}{DSP_MODES}) and length($hash->{helper}{DSP_MODES}) > 0)
{ {
$hash->{helper}{DSP_MODES} .= "|"; $hash->{helper}{DSP_MODES} .= "|";
} }
Log3 $name, 4, "YAMAHA_AVR ($name) - adding DSP mode $1";
$hash->{helper}{DSP_MODES} .= $1; $hash->{helper}{DSP_MODES} .= $1;
} }
} }
else
{
Log3 $name, 4, "YAMAHA_AVR ($name) - no DSP modes found in XML";
}
# uncommented line for zone detection testing # uncommented line for zone detection testing
# #
# $hash->{helper}{ZONES} .= "|Zone_2"; # $hash->{helper}{ZONES} .= "|Zone_2";
@ -1260,7 +1272,7 @@ YAMAHA_AVR_ParseXML($$$)
# if explicitly given in the define command, set the desired zone # if explicitly given in the define command, set the desired zone
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})))
{ {
Log3 $name, 4, "YAMAHA_AVR ($name) - using zone ".YAMAHA_AVR_getParamName($hash, lc $hash->{helper}{SELECTED_ZONE}, $hash->{helper}{ZONES}); Log3 $name, 4, "YAMAHA_AVR ($name) - using ".YAMAHA_AVR_getParamName($hash, lc $hash->{helper}{SELECTED_ZONE}, $hash->{helper}{ZONES})." as active zone";
$hash->{ACTIVE_ZONE} = lc $hash->{helper}{SELECTED_ZONE}; $hash->{ACTIVE_ZONE} = lc $hash->{helper}{SELECTED_ZONE};
} }
else else
@ -1308,7 +1320,7 @@ sub YAMAHA_AVR_getInputs($)
YAMAHA_AVR_SendCommand($hash, "<YAMAHA_AV cmd=\"GET\"><$zone><Input><Input_Sel_Item>GetParam</Input_Sel_Item></Input></$zone></YAMAHA_AV>", "statusRequest","getInputs"); YAMAHA_AVR_SendCommand($hash, "<YAMAHA_AV cmd=\"GET\"><$zone><Input><Input_Sel_Item>GetParam</Input_Sel_Item></Input></$zone></YAMAHA_AV>", "statusRequest","getInputs");
# query all available scenes (only in mainzone available) # query all available scenes (only in mainzone available)
YAMAHA_AVR_SendCommand($hash, "<YAMAHA_AV cmd=\"GET\"><$zone><Scene><Scene_Sel_Item>GetParam</Scene_Sel_Item></Scene></$zone></YAMAHA_AV>", "statusRequest","getScenes") if($hash->{helper}{SELECTED_ZONE} eq "mainzone"); YAMAHA_AVR_SendCommand($hash, "<YAMAHA_AV cmd=\"GET\"><$zone><Scene><Scene_Sel_Item>GetParam</Scene_Sel_Item></Scene></$zone></YAMAHA_AV>", "statusRequest","getScenes") if($hash->{ACTIVE_ZONE} eq "mainzone");
} }
############################# #############################