From 38f4f510f175b450e3d38e9158cc6bad8500a055 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Mon, 12 Apr 2021 08:40:15 +0200 Subject: [PATCH] change part of code --- 74_CometBlueBTLE.pm | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/74_CometBlueBTLE.pm b/74_CometBlueBTLE.pm index 337a5bd..c22dae9 100644 --- a/74_CometBlueBTLE.pm +++ b/74_CometBlueBTLE.pm @@ -421,7 +421,7 @@ sub Set($$@) { #return 'CometBlueBTLE: desired-temp supports temperatures from 6.0 - 28.0 degrees' if($args[0]<8.0 or $args[0]>28.0 or $args[0] ne 'on' or $args[0] ne 'off'); $handle = $gatttChar{ AttrVal( $name, 'model', '' ) }{'payload'}; - $value = join( " ", @args ); + $value = join( ' ', @args ); } elsif ( $cmd eq 'tempEco' ) { @@ -433,7 +433,7 @@ sub Set($$@) { if ( $args[0] < 12.0 or $args[0] > 23.0 ); $handle = $gatttChar{ AttrVal( $name, 'model', '' ) }{'payload'}; - $value = join( " ", @args ); + $value = join( ' ', @args ); } elsif ( $cmd eq 'tempComfort' ) { @@ -445,7 +445,7 @@ sub Set($$@) { if ( $args[0] < 12.0 or $args[0] > 23.0 ); $handle = $gatttChar{ AttrVal( $name, 'model', '' ) }{'payload'}; - $value = join( " ", @args ); + $value = join( ' ', @args ); } elsif ( $cmd eq 'tempOffset' ) { @@ -455,7 +455,7 @@ sub Set($$@) { if ( $args[0] < -5.0 or $args[0] > 5.0 ); $handle = $gatttChar{ AttrVal( $name, 'model', '' ) }{'payload'}; - $value = join( " ", @args ); + $value = join( ' ', @args ); } elsif ( $cmd eq 'winOpnSensitivity' ) { @@ -464,7 +464,7 @@ sub Set($$@) { if ( @args != 1 ); $handle = $gatttChar{ AttrVal( $name, 'model', '' ) }{'payload'}; - $value = join( " ", @args ); + $value = join( ' ', @args ); } elsif ( $cmd eq 'winOpnPeriod' ) { @@ -473,7 +473,7 @@ sub Set($$@) { if ( @args != 1 ); $handle = $gatttChar{ AttrVal( $name, 'model', '' ) }{'payload'}; - $value = join( " ", @args ); + $value = join( ' ', @args ); } elsif ( $cmd eq 'resetBatteryTimestamp' ) { @@ -482,6 +482,14 @@ sub Set($$@) { $hash->{helper}{updateTimeCallBattery} = 0; return; + } + elsif ( $cmd eq 'mode' ) { + return "usage: mode value" if ( @args != 1 ); + Log3 $name, 2, + 'CometBlueBTLE ($name) - set mit Value: ' . join( ' ', @args ); + readingsSingleUpdate($hash,'mode',join( ' ', @args ),0); + return; + } else { my $list = @@ -493,7 +501,7 @@ sub Set($$@) { $list .= " tempComfort:12.0,12.5,13.0,13.5,14.0,14.5,15.0,15.5,16.0,16.5,17.0,17.5,18.0,18.5,19.0,19.5,20.0,20.5,21.0,21.5,22.0,22.5,23.0"; $list .= -" tempOffset:-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5 winOpnSensitivity:high,medium,low winOpnPeriod:slider,5,5,30 resetBatteryTimestamp:noArg"; +" tempOffset:-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5 mode:manual,auto winOpnSensitivity:high,medium,low winOpnPeriod:slider,5,5,30 resetBatteryTimestamp:noArg"; return "Unknown argument $cmd, choose one of $list"; } @@ -1019,7 +1027,7 @@ sub HandlePayload($$) { # 04 = Fenster offen Detektor # 0a= Zeit Fenster offen in Minuten - $readings{'measured-temp'} = hex( "0x" . $payload[0] ) / 2; + $readings{'measured-temp'} = sprintf( "%.1f",hex( "0x" . $payload[0] ) / 2); if ( hex( "0x" . $payload[1] ) / 2 == 7.5 ) { $readings{'desired-temp'} = 'off'; @@ -1028,17 +1036,17 @@ sub HandlePayload($$) { $readings{'desired-temp'} = 'on'; } else { - $readings{'desired-temp'} = hex( "0x" . $payload[1] ) / 2; + $readings{'desired-temp'} = sprintf( "%.1f",hex( "0x" . $payload[1] ) / 2); } - $readings{'tempEco'} = hex( "0x" . $payload[2] ) / 2; - $readings{'tempComfort'} = hex( "0x" . $payload[3] ) / 2; + $readings{'tempEco'} = sprintf( "%.1f",hex( "0x" . $payload[2] ) / 2); + $readings{'tempComfort'} = sprintf( "%.1f",hex( "0x" . $payload[3] ) / 2); if ( $payload[4] =~ /^f/ ) { - $readings{'tempOffset'} = ( hex( "0x" . $payload[4] ) / 2 ) - 128; + $readings{'tempOffset'} = ( sprintf( "%.1f",hex( "0x" . $payload[4] ) / 2) ) - 128; } else { - $readings{'tempOffset'} = hex( "0x" . $payload[4] ) / 2; + $readings{'tempOffset'} = sprintf( "%.1f",hex( "0x" . $payload[4] ) / 2); } $readings{'winOpnSensitivity'} =