diff --git a/fhem/CHANGED b/fhem/CHANGED
index 901c20a79..7263b3c47 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.
+ - feature: 71_YAMAHA_NP.pm: New readings: tunerModeDAB, tunerBitrateDAB, tunerAudioModeDAB, tunerFrequencyDAB. New internals: NP_ICON_x, UDN, Friendly_Name
- changed: 73_km200.pm: More services found.
- bugfix: FB_CALLMONITOR: read phonebooks after all attributes are set
from fhem.cfg.
diff --git a/fhem/FHEM/71_YAMAHA_NP.pm b/fhem/FHEM/71_YAMAHA_NP.pm
index ac64c6374..049bf6f9a 100644
--- a/fhem/FHEM/71_YAMAHA_NP.pm
+++ b/fhem/FHEM/71_YAMAHA_NP.pm
@@ -197,7 +197,7 @@ sub YAMAHA_NP_Set($@)
"timerVolume:slider,".$volumeStraightMin.",1,".$volumeStraightMax." ".
"mute:on,off ".
(exists($hash->{helper}{INPUTS})?"input:".$inputs_comma." ":"").
- "statusRequest:basicStatus,networkInfo,playerStatus,systemConfig,timerStatus,tunerPresetDAB,tunerPresetFM,tunerStatus ".
+ "statusRequest:basicStatus,mediaRendererDesc,playerStatus,systemConfig,timerStatus,tunerPresetDAB,tunerPresetFM,tunerStatus ".
"standbyMode:eco,normal ".
"cdTray:noArg ".
"timer:on,off ".
@@ -223,7 +223,7 @@ sub YAMAHA_NP_Set($@)
"timerVolume:slider,".$volumeStraightMin.",1,".$volumeStraightMax." ".
"mute:on,off ".
(exists($hash->{helper}{INPUTS})?"input:".$inputs_comma." ":"").
- "statusRequest:basicStatus,networkInfo,playerStatus,systemConfig,timerStatus,tunerPresetFM,tunerStatus ".
+ "statusRequest:basicStatus,mediaRendererDesc,networkInfo,playerStatus,systemConfig,timerStatus,tunerPresetFM,tunerStatus ".
"standbyMode:eco,normal ".
"cdTray:noArg ".
"timer:on,off ".
@@ -505,6 +505,10 @@ sub YAMAHA_NP_Set($@)
{
YAMAHA_NP_SendCommand($hash, "GetParam", $what, $a[2]);
}
+ elsif($a[2] eq "mediaRendererDesc")
+ {
+ YAMAHA_NP_getMediaRendererDesc($hash);
+ }
else
{
return $usage;
@@ -822,10 +826,13 @@ sub YAMAHA_NP_ParseResponse ($$$)
$hash->{helper}{AVAILABLE} = 1;
- if(not $data =~ /RC="0"/)
+ if ($cmd ne "statusRequest" and $arg ne "systemConfig") # RC="0" is not delivered by that status Request
{
- # if the returncode isn't 0, than the command was not successful
- Log3 $name, 3, "YAMAHA_NP ($name) - Could not execute \"$cmd".(defined($arg) ? " ".(split("\\|", $arg))[0] : "")."\"";
+ if(not $data =~ /RC="0"/)
+ {
+ # if the returncode isn't 0, than the command was not successful
+ Log3 $name, 3, "YAMAHA_NP ($name) - Could not execute \"$cmd".(defined($arg) ? " ".(split("\\|", $arg))[0] : "")."\"";
+ }
}
readingsBeginUpdate($hash);
@@ -998,6 +1005,31 @@ sub YAMAHA_NP_ParseResponse ($$$)
{
readingsBulkUpdate($hash, "tunerEnsembleLabelDAB", YAMAHA_NP_html2txt($1));
}
+ if($data =~ /(.+)<\/Bit_Rate>/)
+ {
+ readingsBulkUpdate($hash, "tunerBitRateDAB", $1." kbit\/s");
+ }
+ if($data =~ /(.+)<\/Audio_Mode>/)
+ {
+ readingsBulkUpdate($hash, "tunerAudioModeDAB", $1);
+ }
+ if($data =~ /(.+)<\/DAB_PLUS>/)
+ {
+ if($1 eq "Negate")
+ {
+ readingsBulkUpdate($hash, "tunerModeDAB", "DAB");
+ }
+ elsif($1 eq "Assert")
+ {
+ readingsBulkUpdate($hash, "tunerModeDAB", "DAB+");
+ }
+ }
+ if($data =~ /(.+)<\/Freq>/)
+ {
+ my $frequency = $1;
+ $frequency =~ s/(\d{3})$/.$1/; # Insert '.' to frequency
+ readingsBulkUpdate($hash, "tunerFrequencyDAB", $frequency." MHz");
+ }
}
elsif($arg eq "timerStatus")
{
@@ -1082,6 +1114,41 @@ sub YAMAHA_NP_ParseResponse ($$$)
}
}
}
+ elsif ($arg eq "mediaRendererDesc")
+ {
+ if($data =~ /(.+)<\/friendlyName>/)
+ {
+ $hash->{FRIENDLY_NAME} = $1;
+ }
+
+ if($data =~ /(.+)<\/UDN>/)
+ {
+ $hash->{UNIQUE_DEVICE_NAME} = $1;
+ }
+
+ # Replace \n, \r, \t from the string for XML parsing
+
+ # replace \n by ""
+ $data =~ s/\n//g;
+
+ # replace \t by ""
+ $data =~ s/\t//g;
+
+ # replace \r by ""
+ $data =~ s/\r//g;
+
+ if($data =~ /(.+?)<\/iconList>/)
+ {
+ my $address = $hash->{helper}{ADDRESS};
+ my $i = 1;
+
+ while ($data =~ /(.+?)<\/url>/g)
+ {
+ $hash->{"NP_ICON_$i"} = "http://".$address.":8080".$1;
+ $i++;
+ }
+ }
+ }
}
elsif($cmd eq "on")
{
@@ -1182,8 +1249,33 @@ sub YAMAHA_NP_getModel($)
my ($hash) = @_;
YAMAHA_NP_SendCommand($hash, "GetParam", "statusRequest","systemConfig");
+ YAMAHA_NP_getMediaRendererDesc($hash);
}
+#############################
+# queries the receiver model, system-id, version and all available zones
+sub YAMAHA_NP_getMediaRendererDesc($)
+{
+ my ($hash) = @_;
+ my $name = $hash->{NAME};
+ my $address = $hash->{helper}{ADDRESS};
+
+ Log3 $name, 5, "YAMAHA_NP ($name) - execute nonblocking \"MediaRendererDesc\"";
+
+ HttpUtils_NonblockingGet
+ ({
+ url => "http://".$address.":8080/MediaRenderer/desc.xml",
+ timeout => AttrVal($name, "request-timeout", 4),
+ noshutdown => 1,
+ data => "",
+ loglevel => ($hash->{helper}{AVAILABLE} ? undef : 5),
+ hash => $hash,
+ cmd => "statusRequest",
+ arg => "mediaRendererDesc",
+ callback => \&YAMAHA_NP_ParseResponse
+ });
+}
+
#############################
# converts straight volume in percentage volume (volumestraightmin .. volumestraightmax => 0 .. 100%)
sub YAMAHA_NP_volume_rel2abs($$)
@@ -1480,9 +1572,13 @@ sub YAMAHA_NP_html2txt($)
playerAlbumArtID - Reports the album art ID (if available) of the currently played audio.
playerAlbumArtFormat - Reports the album art format (if available) of the currently played audio.
Tuner related readings:
+ tunerAudioModeDAB - Reports current audio mode (Mono|Stereo).
tunerBand - Reports the currently selected tuner band (FM|DAB). DAB if available.
+ tunerBitRateDAB - Reports current DAB stream bit rate (kbit/s).
tunerPresetFM - Reports the currently selected FM preset. If stored as such (1...30).
+ tunerFrequencyDAB - Reports the currently tuned DAB frequency. (xxx.xxx MHz)
tunerFrequencyFM - Reports the currently tuned FM frequency. (xxx.xx MHz)
+ tunerModeDAB - Reports current DAB audio mode (Mono|Stereo).
tunerProgramServiceFM - Reports the FM service name.
tunerRadioTextAFM - Reports the Radio Text A of the selected FM service.
tunerRadioTextBFM - Reports the Radio Text B of the selected FM service.
@@ -1700,7 +1796,11 @@ sub YAMAHA_NP_html2txt($)
playerAlbumArtID - Abfrage der AlbumArtID (falls verfügbar) der aktuellen Wiedergabe.
playerAlbumArtFormat - Abfrage des AlbumArt Formats (falls verfügbar) der aktuellen Wiedergabe.
Tuner Readings:
+ tunerAudioModeDAB - Abfrage des aktuellen DAB Audio-Modus (Mono|Stereo)..
tunerBand - Abfrage des aktuellen Radio-Bandes (FM|DAB). DAB falls verfügbar.
+ tunerBitRate - Abfrage der aktuellen DAB Stream Bitrate (kbit/s).
+ tunerModeDAB - Abfrage des aktuellen DAB Modus (DAB|DAB+).
+ tunerFrequencyDAB - Abfrage der aktuellen DAB Frequenz. (xxx.xxx MHz)
tunerPresetFM - Abfrage der aktuellen FM Voreinstellung. Falls gespeichtert (1...30).
tunerFrequencyFM - Abfrage der aktuellen FM Frequenz. (xxx.xx MHz)
tunerProgramServiceFM - Abfrage des FM Sendernamen.