mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-28 17:12:32 +00:00
71_YAMAHA_NP: More secure FM frequency input.
git-svn-id: https://svn.fhem.de/fhem/trunk@10222 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
0bdb591435
commit
ebd5082102
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- change: 71_YAMAHA_NP: More secure FM frequency input
|
||||||
- feature: FHEMWEB/Event Monitor: optional FHEM Log monitor.
|
- feature: FHEMWEB/Event Monitor: optional FHEM Log monitor.
|
||||||
- feature: 50_Telegrambot: multiple contacts for send etc/removed depreacted
|
- feature: 50_Telegrambot: multiple contacts for send etc/removed depreacted
|
||||||
messageTo,sendImageTo,sendPhotoTo/allowunknowncontacts
|
messageTo,sendImageTo,sendPhotoTo/allowunknowncontacts
|
||||||
|
@ -5,16 +5,21 @@
|
|||||||
# 71_YAMAHA_NP.pm
|
# 71_YAMAHA_NP.pm
|
||||||
#
|
#
|
||||||
# An FHEM Perl module for controlling the Yamaha CD-Receiver CRX-N560(D)
|
# An FHEM Perl module for controlling the Yamaha CD-Receiver CRX-N560(D)
|
||||||
# (aka MCR-N560D) via Ethernet connection.
|
# (aka MCR-N560D) via Ethernet.
|
||||||
# The module should also work with devices controlled by the
|
|
||||||
# Yamaha Network Player App for *OS and Andr*id
|
|
||||||
# (e.g. NP-S2000, CD-N500, CD-N301, R-N500, R-N301).
|
|
||||||
#
|
#
|
||||||
# Copyright by Radoslaw Watroba
|
# The module might also work with devices such as
|
||||||
# (e-mail: ra666ack@googlemail.com)
|
# NP-S2000, CD-N500, CD-N301, R-N500, R-N301 controlled by the
|
||||||
|
# Yamaha Network Player App.
|
||||||
#
|
#
|
||||||
# Inspired by the 71_YAMAHA_AVR module by Markus Bloch
|
# *OS:
|
||||||
# (e-mail: Notausstieg0309@googlemail.com)
|
# https://itunes.apple.com/us/app/network-player-controller-us/id467502483?mt=8
|
||||||
|
#
|
||||||
|
# Andr*id:
|
||||||
|
# https://play.google.com/store/apps/details?id=com.yamaha.npcontroller
|
||||||
|
#
|
||||||
|
# Copyright by Radoslaw Watroba (ra666ack@googlemail.com)
|
||||||
|
#
|
||||||
|
# (Inspired by Markus Bloch and the module 71_YAMAHA_AVR)
|
||||||
#
|
#
|
||||||
# This file is part of fhem.
|
# This file is part of fhem.
|
||||||
#
|
#
|
||||||
@ -249,6 +254,8 @@ sub YAMAHA_NP_Set
|
|||||||
|
|
||||||
Log3 $name, 5, "YAMAHA_NP ($name) - set ".join(" ", @a);
|
Log3 $name, 5, "YAMAHA_NP ($name) - set ".join(" ", @a);
|
||||||
|
|
||||||
|
# Processing of incoming commands.
|
||||||
|
|
||||||
if($what eq "on")
|
if($what eq "on")
|
||||||
{
|
{
|
||||||
YAMAHA_NP_SendCommand($hash, "<YAMAHA_AV cmd=\"PUT\"><System><Power_Control><Power>On</Power></Power_Control></System></YAMAHA_AV>" ,$what, "On");
|
YAMAHA_NP_SendCommand($hash, "<YAMAHA_AV cmd=\"PUT\"><System><Power_Control><Power>On</Power></Power_Control></System></YAMAHA_AV>" ,$what, "On");
|
||||||
@ -285,17 +292,17 @@ sub YAMAHA_NP_Set
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "No inputs are avaible. Please try an statusUpdate.";
|
return "No inputs avaible. Please try an statusRequest.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "input can only be used when device is powered on";
|
return "Switch device on first.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $inputs_piped eq "" ? "No inputs are available. Please try an statusUpdate." : "No input parameter was given";
|
return $inputs_piped eq "" ? "No inputs available. Please try an statusRequest first." : "No input parameter given.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif($what eq "mute")
|
elsif($what eq "mute")
|
||||||
@ -319,7 +326,7 @@ sub YAMAHA_NP_Set
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "mute can only used when device is powered on";
|
return "Switch device on in order to mute it.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -650,7 +657,7 @@ sub YAMAHA_NP_Set
|
|||||||
}
|
}
|
||||||
elsif($what eq "timerVolume")
|
elsif($what eq "timerVolume")
|
||||||
{
|
{
|
||||||
# if lower than minimum VOLUMESTRAIGHTMIN or higher than max VOLUMESTRAIGHTMAX set target volume to the corresponding limts
|
# if lower than minimum VOLUMESTRAIGHTMIN or higher than max VOLUMESTRAIGHTMAX set target volume to the corresponding limits
|
||||||
if($a[2] >= $hash->{helper}{VOLUMESTRAIGHTMIN} and $a[2] <= $hash->{helper}{VOLUMESTRAIGHTMAX})
|
if($a[2] >= $hash->{helper}{VOLUMESTRAIGHTMIN} and $a[2] <= $hash->{helper}{VOLUMESTRAIGHTMAX})
|
||||||
{
|
{
|
||||||
$hash->{helper}{timerVolume} = $a[2];
|
$hash->{helper}{timerVolume} = $a[2];
|
||||||
@ -695,10 +702,17 @@ sub YAMAHA_NP_Set
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif($what eq "tunerFMFrequency")
|
elsif($what eq "tunerFMFrequency")
|
||||||
|
{
|
||||||
|
if(length($a[2]) <= 6 and length($a[2]) >= 5) # Check the string length (x)xx.xx
|
||||||
{
|
{
|
||||||
if ( $a[2] =~ /^[0-9,.E]+$/ ) # Check if value is numeric
|
if ( $a[2] =~ /^[0-9,.E]+$/ ) # Check if value is numeric
|
||||||
{
|
{
|
||||||
if( $a[2] >= 87.50 and $a[2] <= 108.00)
|
if( $a[2] >= 87.50 and $a[2] <= 108.00) # Check if within the value range
|
||||||
|
{
|
||||||
|
if(substr($a[2], -3, 1) eq '.') # Check for decimal point
|
||||||
|
{
|
||||||
|
my $lastDigit = substr($a[2], -1, 1);
|
||||||
|
if(($lastDigit eq "0") or ($lastDigit eq "5"))
|
||||||
{
|
{
|
||||||
my $frequency = $a[2];
|
my $frequency = $a[2];
|
||||||
$frequency =~ s/\.//; # Remove decimal point
|
$frequency =~ s/\.//; # Remove decimal point
|
||||||
@ -706,12 +720,27 @@ sub YAMAHA_NP_Set
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "Frequency value must be in the range 87.50 ... 108.00 of the format (x)xx.xx"
|
return "Last digit must be '0' or '5'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "Frequency value must be numeric in the range 87.50 ... 108.00 of the format (x)xx.xx"
|
return "Missing decimal point. Accepted format (x)xx.xx"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "Frequency value must be in the range 87.50 ... 108.00 of the format (x)xx.xx";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "Frequency value must be numeric in the range 87.50 ... 108.00 of the format (x)xx.xx";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "Frequency length must be 5 or 6 characters e.g. 89.50 or 108.00";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1369,7 +1398,7 @@ sub YAMAHA_NP_ParseResponse
|
|||||||
readingsBulkUpdate($hash, "volume", YAMAHA_NP_volume_abs2rel($hash, $hash->{helper}{targetVolume}));
|
readingsBulkUpdate($hash, "volume", YAMAHA_NP_volume_abs2rel($hash, $hash->{helper}{targetVolume}));
|
||||||
# New "volume"value: The CRX-N560D cannot provide the current volume in time after a volume change.
|
# New "volume"value: The CRX-N560D cannot provide the current volume in time after a volume change.
|
||||||
# Therefore updated locally.
|
# Therefore updated locally.
|
||||||
# Volume will be updated during the next timer loop.
|
# Volume will be updated during the next statusRequest timer loop.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1545,6 +1574,7 @@ sub YAMAHA_NP_html2txt
|
|||||||
1;
|
1;
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
|
|
||||||
=begin html
|
=begin html
|
||||||
|
|
||||||
<a name="YAMAHA_NP"></a>
|
<a name="YAMAHA_NP"></a>
|
||||||
@ -1675,7 +1705,6 @@ sub YAMAHA_NP_html2txt
|
|||||||
<li><b>volumeUp</b> [<VOL_MIN>...<VOL_MAX>] - increases the volume by one device's absolute step. <VOL_MIN> and <VOL_MAX> are read and set from the device automatically.</li>
|
<li><b>volumeUp</b> [<VOL_MIN>...<VOL_MAX>] - increases the volume by one device's absolute step. <VOL_MIN> and <VOL_MAX> are read and set from the device automatically.</li>
|
||||||
<li><b>volumeDown</b> [<VOL_MIN>...<VOL_MAX>] - increases the volume by one device's absolute step. <VOL_MIN> and <VOL_MAX> are read and set from the device automatically.</li>
|
<li><b>volumeDown</b> [<VOL_MIN>...<VOL_MAX>] - increases the volume by one device's absolute step. <VOL_MIN> and <VOL_MAX> are read and set from the device automatically.</li>
|
||||||
</ul><br><br>
|
</ul><br><br>
|
||||||
|
|
||||||
A typical example is powering the device remotely and tuning the favourite radio station:<br><br>
|
A typical example is powering the device remotely and tuning the favourite radio station:<br><br>
|
||||||
Add the following code into the <b>fhem.cfg</b> configuration file:<br><br><br>
|
Add the following code into the <b>fhem.cfg</b> configuration file:<br><br><br>
|
||||||
<ul>
|
<ul>
|
||||||
@ -1701,7 +1730,6 @@ sub YAMAHA_NP_html2txt
|
|||||||
</ul>
|
</ul>
|
||||||
<br><br>
|
<br><br>
|
||||||
It's a good idea to insert a 'sleep' instruction between each fhem commands due to internal processing time of the network player. During that time the following commands might be ignored...<br><br>
|
It's a good idea to insert a 'sleep' instruction between each fhem commands due to internal processing time of the network player. During that time the following commands might be ignored...<br><br>
|
||||||
|
|
||||||
Now the function can be called by typing the following line in the FHEM command line or by the notify-definitions:<br><br>
|
Now the function can be called by typing the following line in the FHEM command line or by the notify-definitions:<br><br>
|
||||||
<ul>
|
<ul>
|
||||||
<code>
|
<code>
|
||||||
@ -1801,7 +1829,9 @@ sub YAMAHA_NP_html2txt
|
|||||||
However, even if the standbyMode is set to "Eco" the device can be powered off. In that case it has to be switched on manually.<br>
|
However, even if the standbyMode is set to "Eco" the device can be powered off. In that case it has to be switched on manually.<br>
|
||||||
</ul><br>
|
</ul><br>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
=end html
|
=end html
|
||||||
|
|
||||||
=begin html_DE
|
=begin html_DE
|
||||||
|
|
||||||
<a name="YAMAHA_NP"></a>
|
<a name="YAMAHA_NP"></a>
|
||||||
@ -2048,5 +2078,7 @@ sub YAMAHA_NP_html2txt
|
|||||||
Das Abschalten funktioniert auch standbyMode "Normal" Modus.<br>
|
Das Abschalten funktioniert auch standbyMode "Normal" Modus.<br>
|
||||||
</ul><br>
|
</ul><br>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
=end html_DE
|
=end html_DE
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
Loading…
x
Reference in New Issue
Block a user