split create volume value in to seperate Methode
This commit is contained in:
parent
7419e4381c
commit
b67b1df6be
@ -58,7 +58,7 @@ eval "use Encode qw(encode encode_utf8);1" or $missingModul .= "Encode ";
|
|||||||
eval "use JSON;1" or $missingModul .= "JSON ";
|
eval "use JSON;1" or $missingModul .= "JSON ";
|
||||||
|
|
||||||
|
|
||||||
my $modulversion = "4.0.8";
|
my $modulversion = "4.0.9";
|
||||||
my $flowsetversion = "4.0.7";
|
my $flowsetversion = "4.0.7";
|
||||||
|
|
||||||
|
|
||||||
@ -77,6 +77,7 @@ sub AMADDevice_Set($$@);
|
|||||||
sub AMADDevice_Undef($$);
|
sub AMADDevice_Undef($$);
|
||||||
sub AMADDevice_Parse($$);
|
sub AMADDevice_Parse($$);
|
||||||
sub AMADDevice_statusRequest($);
|
sub AMADDevice_statusRequest($);
|
||||||
|
sub AMADDevice_CreateVolumeValue($$@);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -468,43 +469,7 @@ sub AMADDevice_Set($$@) {
|
|||||||
|
|
||||||
elsif( lc $cmd eq 'volume' or $cmd eq 'mute' or $cmd =~ 'volume[Down|Up]' ) {
|
elsif( lc $cmd eq 'volume' or $cmd eq 'mute' or $cmd =~ 'volume[Down|Up]' ) {
|
||||||
|
|
||||||
my $vol;
|
my $vol = AMADDevice_CreateVolumeValue($hash,$cmd,@args);
|
||||||
|
|
||||||
if( $cmd eq 'volume' ) {
|
|
||||||
$vol = join( " ", @args );
|
|
||||||
|
|
||||||
if( $vol =~ /^\+(.*)/ or $vol =~ /^-(.*)/ ) {
|
|
||||||
|
|
||||||
if( $vol =~ /^\+(.*)/ ) {
|
|
||||||
|
|
||||||
$vol =~ s/^\+//g;
|
|
||||||
$vol = ReadingsVal( $name, "volume", 0 ) + $vol;
|
|
||||||
}
|
|
||||||
|
|
||||||
elsif( $vol =~ /^-(.*)/ ) {
|
|
||||||
|
|
||||||
$vol =~ s/^-//g;
|
|
||||||
printf $vol;
|
|
||||||
$vol = ReadingsVal( $name, "volume", 15 ) - $vol;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} elsif( $cmd eq 'mute') {
|
|
||||||
if($args[0] eq 'on') {
|
|
||||||
$vol = 0;
|
|
||||||
readingsSingleUpdate($hash,'.volume',ReadingsVal($name,'volume',0),0);
|
|
||||||
} else {
|
|
||||||
$vol = ReadingsVal($name,'.volume',0);
|
|
||||||
}
|
|
||||||
|
|
||||||
} elsif( $cmd =~ 'volume[Down|Up]') {
|
|
||||||
if( $cmd eq 'volumeUp' ) {
|
|
||||||
$vol = ReadingsVal( $name, "volume", 0 ) + AttrVal($name,'setVolUpDownStep',3);
|
|
||||||
} else {
|
|
||||||
$vol = ReadingsVal( $name, "volume", 0 ) - AttrVal($name,'setVolUpDownStep',3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$uri = $host . ":" . $port . "/fhem-amad/setCommands/setVolume?volume=$vol";
|
$uri = $host . ":" . $port . "/fhem-amad/setCommands/setVolume?volume=$vol";
|
||||||
$method = "POST";
|
$method = "POST";
|
||||||
@ -885,6 +850,51 @@ sub AMADDevice_decrypt($) {
|
|||||||
return $decodedPIN;
|
return $decodedPIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub AMADDevice_CreateVolumeValue($$@) {
|
||||||
|
|
||||||
|
my ($hash,$cmd,@args) = @_;
|
||||||
|
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
my $vol;
|
||||||
|
|
||||||
|
|
||||||
|
if( $cmd eq 'volume' ) {
|
||||||
|
$vol = join( " ", @args );
|
||||||
|
|
||||||
|
if( $vol =~ /^\+(.*)/ or $vol =~ /^-(.*)/ ) {
|
||||||
|
|
||||||
|
if( $vol =~ /^\+(.*)/ ) {
|
||||||
|
|
||||||
|
$vol =~ s/^\+//g;
|
||||||
|
$vol = ReadingsVal( $name, "volume", 0 ) + $vol;
|
||||||
|
}
|
||||||
|
|
||||||
|
elsif( $vol =~ /^-(.*)/ ) {
|
||||||
|
|
||||||
|
$vol =~ s/^-//g;
|
||||||
|
$vol = ReadingsVal( $name, "volume", 15 ) - $vol;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} elsif( $cmd eq 'mute') {
|
||||||
|
if($args[0] eq 'on') {
|
||||||
|
$vol = 0;
|
||||||
|
readingsSingleUpdate($hash,'.volume',ReadingsVal($name,'volume',0),0);
|
||||||
|
} else {
|
||||||
|
$vol = ReadingsVal($name,'.volume',0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} elsif( $cmd =~ 'volume[Down|Up]') {
|
||||||
|
if( $cmd eq 'volumeUp' ) {
|
||||||
|
$vol = ReadingsVal( $name, "volume", 0 ) + AttrVal($name,'setVolUpDownStep',3);
|
||||||
|
} else {
|
||||||
|
$vol = ReadingsVal( $name, "volume", 0 ) - AttrVal($name,'setVolUpDownStep',3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $vol;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user