diff --git a/FHEM/00_SIGNALduino.pm b/FHEM/00_SIGNALduino.pm index 5a6e031aa..471012e61 100644 --- a/FHEM/00_SIGNALduino.pm +++ b/FHEM/00_SIGNALduino.pm @@ -1,4 +1,4 @@ -# $Id: 00_SIGNALduino.pm 3.5.5 2023-01-15 02:03:31Z sidey79 $ +# $Id: 00_SIGNALduino.pm 3.5.5 2023-01-23 17:24:05Z sidey79 $ # v3.5.5 - https://github.com/RFD-FHEM/RFFHEM/tree/master # The module is inspired by the FHEMduino project and modified in serval ways for processing the incoming messages # see http://www.fhemwiki.de/wiki/SIGNALDuino @@ -15,6 +15,7 @@ package main; use strict; use warnings; use Storable qw(dclone); +use FHEM::Core::Utils::Math; #use version 0.77; our $VERSION = version->declare('v3.5.5'); my $missingModulSIGNALduino = ' '; @@ -37,11 +38,11 @@ use List::Util qw(first); #$| = 1; #Puffern abschalten, Hilfreich fuer PEARL WARNINGS Search -#use Math::Round qw(); + use constant { - SDUINO_VERSION => '3.5.5+20230115', # Datum wird automatisch bei jedem pull request aktualisiert + SDUINO_VERSION => '3.5.5+20230123', # Datum wird automatisch bei jedem pull request aktualisiert SDUINO_INIT_WAIT_XQ => 1.5, # wait disable device SDUINO_INIT_WAIT => 2, SDUINO_INIT_MAXRETRY => 3, @@ -389,11 +390,6 @@ sub SIGNALduino_Define { DevIo_CloseDev($hash); my $name = $a[0]; - if (!exists &round) - { - Log3 $name, 1, "$name: Define, Signalduino can't be activated (sub round not found). Please update Fhem via update command"; - return ; - } my $dev = $a[2]; #Debug "dev: $dev" if ($debug); @@ -861,7 +857,7 @@ sub SIGNALduino_Set_sendMsg { if (defined($hash->{protocolObject}->getProperty($protocol,'format')) && $hash->{protocolObject}->getProperty($protocol,'format') eq 'manchester') { $clock += $_ for( @{$hash->{protocolObject}->getProperty($protocol,'clockrange')} ); - $clock = round($clock/2,0); + $clock = FHEM::Core::Utils::Math::round($clock/2,0); my $intro; my $outro; @@ -1218,7 +1214,7 @@ sub SIGNALduino_CheckccConfResponse { if ($msg2 !~ /Modulation:\sASK\/OOK/) { $msg2 .= ", Syncmod: ".$syncmod[($r{"12"})&7]; #Syncmod | Register 0x12 - $msg2 .= ", Deviation: ".round((8+($r{"15"}&7))*(2**(($r{"15"}>>4)&7)) *26000/(2**17),2) .' kHz'; #Deviation | Register 0x15 + $msg2 .= ", Deviation: ".FHEM::Core::Utils::Math::round((8+($r{"15"}&7))*(2**(($r{"15"}>>4)&7)) *26000/(2**17),2) .' kHz'; #Deviation | Register 0x15 } readingsBeginUpdate($_[0]); @@ -2379,7 +2375,7 @@ sub SIGNALduino_Parse_MS { #Debug 'List of pattern:'; my $clockabs= $msg_parts{pattern}{$msg_parts{clockidx}}; return if ($clockabs == 0); - $patternList{$_} = round($msg_parts{pattern}{$_}/$clockabs,1) for keys %{$msg_parts{pattern}}; + $patternList{$_} = FHEM::Core::Utils::Math::round($msg_parts{pattern}{$_}/$clockabs,1) for keys %{$msg_parts{pattern}}; #Debug Dumper(\%patternList); @@ -2607,10 +2603,10 @@ sub SIGNALduino_Parse_MU { (my $count_changes,$rawData,my %patternListRaw_tmp) = $method->($name,$id,$rawData,%patternListRaw); use strict "refs"; - %patternList = map { $_ => round($patternListRaw_tmp{$_}/$clockabs,1) } keys %patternListRaw_tmp; + %patternList = map { $_ => FHEM::Core::Utils::Math::round($patternListRaw_tmp{$_}/$clockabs,1) } keys %patternListRaw_tmp; } } else { - %patternList = map { $_ => round($patternListRaw{$_}/$clockabs,1) } keys %patternListRaw; + %patternList = map { $_ => FHEM::Core::Utils::Math::round($patternListRaw{$_}/$clockabs,1) } keys %patternListRaw; } Debug qq[Testing against protocol id $id -> ]. $hash->{protocolObject}->getProperty($id,'name') if ($debug); @@ -4180,7 +4176,7 @@ sub CalcDataRate { $DRATE_E = int($DRATE_E); my $DRATE_M = (($dr*1000) * (2**28) / (26000000 * (2**$DRATE_E))) - 256; - my $DRATE_Mr = main::round($DRATE_M,0); + my $DRATE_Mr = FHEM::Core::Utils::Math::round($DRATE_M,0); $DRATE_M = int($DRATE_M); my $datarate0 = ( ((256+$DRATE_M)*(2**($DRATE_E & 15 )))*26000000/(2**28) / 1000); diff --git a/FHEM/14_SD_AS.pm b/FHEM/14_SD_AS.pm index 61b449dfa..ac033bc53 100644 --- a/FHEM/14_SD_AS.pm +++ b/FHEM/14_SD_AS.pm @@ -1,5 +1,5 @@ ############################################## -# $Id: 14_SD_AS.pm 350 2023-01-09 19:54:08Z sidey79 $ +# $Id: 14_SD_AS.pm 350 2023-01-23 17:24:05Z sidey79 $ # The file is part of the SIGNALduino project # see http://www.fhemwiki.de/wiki/SIGNALduino # and was created to provide support for self build sensors. @@ -15,6 +15,7 @@ use strict; use warnings; use POSIX; use FHEM::Meta; +use FHEM::Core::Utils::Math; ##################################### sub @@ -205,7 +206,7 @@ SD_AS_Parse $batteryVoltage = $Sigval; # $bat = (hex(substr($msg,7,2))>>1)&3; # ??? $bat = hex(substr($rawData,2,2))>>6; - $Sigval = round($Sigval / 1000, 2); # Vcc is send in millivolts + $Sigval = FHEM::Core::Utils::Math::round($Sigval / 1000, 2); # Vcc is send in millivolts $val = "V: $Sigval"; } elsif ($model eq "raw") { # 10 diff --git a/FHEM/14_SD_WS.pm b/FHEM/14_SD_WS.pm index cfb98e63a..9dce94087 100644 --- a/FHEM/14_SD_WS.pm +++ b/FHEM/14_SD_WS.pm @@ -1,4 +1,4 @@ -# $Id: 14_SD_WS.pm 26982 2023-01-13 19:55:16Z elektron-bbs $ +# $Id: 14_SD_WS.pm 26982 2023-01-23 17:24:05Z sidey79 $ # # The purpose of this module is to support serval # weather sensors which use various protocol @@ -47,6 +47,8 @@ # 23.05.2022 neues Protokoll 120: Wetterstation TFA 35.1077.54.S2 mit 30.3151 (Thermo/Hygro-Sender), 30.3152 (Regenmesser), 30.3153 (Windmesser) # 11.06.2022 neues Protokoll 122: TM40, Wireless Grill-, Meat-, Roasting-Thermometer with 4 Temperature Sensors # 06.01.2023 neues Protokoll 123: Inkbird IBS-P01R Pool Thermometer, Inkbird ITH-20R (not tested) +# 21.01.2023 use round from package FHEM::Core::Utils::Math; + package main; @@ -56,6 +58,7 @@ use strict; use warnings; use Carp qw(carp); use FHEM::Meta; +use FHEM::Core::Utils::Math; # Forward declarations sub SD_WS_LFSR_digest8_reflect; @@ -386,7 +389,7 @@ sub SD_WS_Parse { } }, id => sub {my (undef,$bitData) = @_; return SD_WS_binaryToNumber($bitData,0,9); }, # id - temp => sub {my (undef,$bitData) = @_; return round(((SD_WS_binaryToNumber($bitData,22,25)*256 + SD_WS_binaryToNumber($bitData,18,21)*16 + SD_WS_binaryToNumber($bitData,14,17)) - 1220) * 5 / 90.0 , 1); }, #temp + temp => sub {my (undef,$bitData) = @_; return FHEM::Core::Utils::Math::round(((SD_WS_binaryToNumber($bitData,22,25)*256 + SD_WS_binaryToNumber($bitData,18,21)*16 + SD_WS_binaryToNumber($bitData,14,17)) - 1220) * 5 / 90.0 , 1); }, #temp hum => sub {my (undef,$bitData) = @_; return (SD_WS_binaryToNumber($bitData,30,33)*16 + SD_WS_binaryToNumber($bitData,26,29)); }, #hum channel => sub {my (undef,$bitData) = @_; return (SD_WS_binaryToNumber($bitData,12,13)+1 ); }, # channel bat => sub {my (undef,$bitData) = @_; return substr($bitData,34,1) eq "0" ? "ok" : "low";}, # other or modul orginal @@ -452,7 +455,7 @@ sub SD_WS_Parse { sendmode => sub {my (undef,$bitData) = @_; return substr($bitData,12,1) eq "1" ? "manual" : "auto";}, bat => sub {my (undef,$bitData) = @_; return substr($bitData,13,1) eq "1" ? "low" : "ok";}, trend => sub {my (undef,$bitData) = @_; return ('consistent', 'rising', 'falling', 'unknown')[SD_WS_binaryToNumber($bitData,14,15)];}, - temp => sub {my (undef,$bitData) = @_; return round(((SD_WS_binaryToNumber($bitData,16,27)) - 1220) * 5 / 90.0 , 1); }, + temp => sub {my (undef,$bitData) = @_; return FHEM::Core::Utils::Math::round(((SD_WS_binaryToNumber($bitData,16,27)) - 1220) * 5 / 90.0 , 1); }, hum => sub {my (undef,$bitData) = @_; return (SD_WS_binaryToNumber($bitData,28,31) * 10) + (SD_WS_binaryToNumber($bitData,32,35));}, channel => sub {my (undef,$bitData) = @_; return (SD_WS_binaryToNumber($bitData,38,39) );}, }, @@ -612,7 +615,7 @@ sub SD_WS_Parse { id => sub {my (undef,$bitData) = @_; return SD_WS_binaryToNumber($bitData,8,15); }, # random id bat => sub {my (undef,$bitData) = @_; return SD_WS_binaryToNumber($bitData,16) eq "1" ? "low" : "ok";}, # bat? channel => sub {my (undef,$bitData) = @_; return (SD_WS_binaryToNumber($bitData,17,19) + 1 ); }, # channel - temp => sub {my (undef,$bitData) = @_; return round((SD_WS_binaryToNumber($bitData,20,31)-720)*0.0556,1); }, # temp + temp => sub {my (undef,$bitData) = @_; return FHEM::Core::Utils::Math::round((SD_WS_binaryToNumber($bitData,20,31)-720)*0.0556,1); }, # temp hum => sub {my ($rawData,$bitData) = @_; return substr($rawData,1,1) eq "5" ? (SD_WS_binaryToNumber($bitData,32,39)) : 0;}, # hum } , 84 => @@ -697,7 +700,7 @@ sub SD_WS_Parse { winddir => sub {my (undef,$bitData) = @_; if (substr($bitData,30,2) eq "10") { # message 2 winddirection $winddir = SD_WS_binaryToNumber($bitData,44,55); - return ($winddir * 1, $winddirtxtar[round(($winddir / 22.5),0)]); + return ($winddir * 1, $winddirtxtar[FHEM::Core::Utils::Math::round(($winddir / 22.5),0)]); } else { return; } @@ -798,7 +801,7 @@ sub SD_WS_Parse { $rawTemp = SD_WS_binaryToNumber($bitData,8,21); my $tempFh = $rawTemp / 20 - 90; # Grad Fahrenheit Log3 $name, 4, "$name: SD_WS_106_T tempraw = $rawTemp, temp = $tempFh Fahrenheit"; - return (round((($tempFh - 32) * 5 / 9) , 1)); # Grad Celsius + return (FHEM::Core::Utils::Math::round((($tempFh - 32) * 5 / 9) , 1)); # Grad Celsius }, crcok => sub {return 1;}, # CRC test method does not exist } , @@ -825,7 +828,7 @@ sub SD_WS_Parse { model => 'SD_WS_107_H', prematch => sub { ($rawData,undef) = @_; return 1 if ($rawData =~ /^51[0-9A-F]{16}[F]{6}/); }, id => sub { my ($rawData,undef) = @_; return substr($rawData,2,6); }, - batVoltage => sub { my (undef,$bitData) = @_; return round(SD_WS_binaryToNumber($bitData,35,39) / 10 , 1); }, + batVoltage => sub { my (undef,$bitData) = @_; return FHEM::Core::Utils::Math::round(SD_WS_binaryToNumber($bitData,35,39) / 10 , 1); }, adc => sub { my (undef,$bitData) = @_; return SD_WS_binaryToNumber($bitData,62,71); }, hum => sub { my ($rawData,undef) = @_; return hex(substr($rawData,12,2)); }, crcok => sub { my $rawData = shift; @@ -981,7 +984,7 @@ sub SD_WS_Parse { return ($rawRainCounterMessage + 10) * 0.1; } }, - temp => sub { my (undef,$bitData) = @_; return round(((SD_WS_binaryToNumber($bitData,48,55) * 256 + SD_WS_binaryToNumber($bitData,40,47)) - 1220) * 5 / 90.0 , 1); }, + temp => sub { my (undef,$bitData) = @_; return FHEM::Core::Utils::Math::round(((SD_WS_binaryToNumber($bitData,48,55) * 256 + SD_WS_binaryToNumber($bitData,40,47)) - 1220) * 5 / 90.0 , 1); }, crcok => sub { my (undef,$bitData) = @_; my $sum = 0; for (my $n = 0; $n < 56; $n += 8) { @@ -1056,13 +1059,13 @@ sub SD_WS_Parse { $rawTemp = SD_WS_binaryToNumber($bitData,12,13) * 256 + SD_WS_binaryToNumber($bitData,16,23); my $tempFh = $rawTemp - 90; # Grad Fahrenheit Log3 $name, 4, "$name: SD_WS_113_T tempraw1 = $rawTemp, temp1 = $tempFh Grad Fahrenheit"; - return (round((($tempFh - 32) * 5 / 9) , 0)); # Grad Celsius + return (FHEM::Core::Utils::Math::round((($tempFh - 32) * 5 / 9) , 0)); # Grad Celsius }, temp2 => sub { my (undef,$bitData) = @_; $rawTemp = SD_WS_binaryToNumber($bitData,14,15) * 256 + SD_WS_binaryToNumber($bitData,24,31); my $tempFh = $rawTemp - 90; # Grad Fahrenheit Log3 $name, 4, "$name: SD_WS_113_T tempraw2 = $rawTemp, temp2 = $tempFh Grad Fahrenheit"; - return (round((($tempFh - 32) * 5 / 9) , 0)); # Grad Celsius + return (FHEM::Core::Utils::Math::round((($tempFh - 32) * 5 / 9) , 0)); # Grad Celsius }, crcok => sub {return 1;}, # Check could not be determined yet. } , @@ -1129,7 +1132,7 @@ sub SD_WS_Parse { winddir => sub {my ($rawData,undef) = @_; return if (substr($rawData,12,1) ne '1' || substr($rawData,20,3) !~ m/^\d+$/xms); # only weather station $winddir = substr($rawData,20,3); - return ($winddir * 1, $winddirtxtar[round(($winddir / 22.5),0)]); + return ($winddir * 1, $winddirtxtar[FHEM::Core::Utils::Math::round(($winddir / 22.5),0)]); }, temp => sub {my ($rawData,$bitData) = @_; # uncoverable condition right @@ -1142,7 +1145,7 @@ sub SD_WS_Parse { $rawTemp *= -1; # Bresser 3in1 } } - return round($rawTemp,1); + return FHEM::Core::Utils::Math::round($rawTemp,1); }, hum => sub {my ($rawData,undef) = @_; # uncoverable condition right @@ -1276,7 +1279,7 @@ sub SD_WS_Parse { id => sub {my ($rawData,undef) = @_; return substr($rawData,4,4); }, winddir => sub {my ($rawData,undef) = @_; $winddir = substr($rawData,8,3); - return ($winddir * 1, $winddirtxtar[round(($winddir / 22.5),0)]); + return ($winddir * 1, $winddirtxtar[FHEM::Core::Utils::Math::round(($winddir / 22.5),0)]); }, batChange => sub {my (undef,$bitData) = @_; return substr($bitData,52,1) eq '0' ? '1' : '0';}, windgust => sub {my ($rawData,undef) = @_; return substr($rawData,14,3) * 0.1;}, @@ -1335,11 +1338,11 @@ sub SD_WS_Parse { }, windspeed => sub {my (undef,$bitData) = @_; return if (substr($bitData,19,1) eq '1'); - return round((SD_WS_binaryToNumber($bitData,39,46) / 3.0),1); + return FHEM::Core::Utils::Math::round((SD_WS_binaryToNumber($bitData,39,46) / 3.0),1); }, windgust => sub {my (undef,$bitData) = @_; return if (substr($bitData,19,1) eq '1'); - return round((SD_WS_binaryToNumber($bitData,47,54) / 3.0),1); + return FHEM::Core::Utils::Math::round((SD_WS_binaryToNumber($bitData,47,54) / 3.0),1); }, rawRainCounter => sub {my (undef,$bitData) = @_; return if (substr($bitData,19,1) eq '1'); diff --git a/FHEM/14_SD_WS09.pm b/FHEM/14_SD_WS09.pm index 4fa507c41..492264f3d 100644 --- a/FHEM/14_SD_WS09.pm +++ b/FHEM/14_SD_WS09.pm @@ -1,5 +1,5 @@ ############################################## -# $Id: 14_SD_WS09.pm 26980 2023-01-09 19:54:08Z sidey79 $ +# $Id: 14_SD_WS09.pm 26980 2023-01-23 17:24:05Z sidey79 $ # # The purpose of this module is to support serval # weather sensors like WS-0101 (Sender 868MHz ASK Epmfänger RX868SH-DV elv) @@ -15,13 +15,14 @@ # 20200127: Corrected line indents @HomeAutoUser # 20200127: fix, WindDirAverage return undef --> return $windDirection_old @HomeAutoUser # 20200127: revised commandref @HomeAutoUser -# +# 20230121 use round from package FHEM::Core::Utils::Math package main; use strict; use warnings; use FHEM::Meta; +use FHEM::Core::Utils::Math; # werden benötigt, aber im Programm noch extra abgetestet #use Digest::CRC qw(crc); @@ -238,9 +239,9 @@ sub SD_WS09_Parse { $windDirection = SD_WS09_bin2dec(substr($sensdata,68,4)); $windDirectionText = $winddir_name[$windDirection]; $windDirectionDegree = $windDirection * 360 / 16; - $windSpeed = round((SD_WS09_bin2dec(substr($sensdata,32,8))* 34)/100,01); + $windSpeed = FHEM::Core::Utils::Math::round((SD_WS09_bin2dec(substr($sensdata,32,8))* 34)/100,01); Log3 $iohash, 4, "$name: SD_WS09_Parse_2 ".$model." id:$id, Windspeed bit: ".substr($sensdata,32,8)." Dec: " . $windSpeed ; - $windguest = round((SD_WS09_bin2dec(substr($sensdata,40,8)) * 34)/100,01); + $windguest = FHEM::Core::Utils::Math::round((SD_WS09_bin2dec(substr($sensdata,40,8)) * 34)/100,01); Log3 $iohash, 4, "$name: SD_WS09_Parse_3 ".$model." id:$id, Windguest bit: ".substr($sensdata,40,8)." Dec: " . $windguest ; $rain = SD_WS09_bin2dec(substr($sensdata,52,12)) * 0.3; Log3 $iohash, 4, "$name: SD_WS09_Parse_4 ".$model." id:$id, Rain bit: ".substr($sensdata,52,12)." Dec: " . $rain ; @@ -312,11 +313,11 @@ sub SD_WS09_Parse { $windDirection = SD_WS09_bin2dec(substr($sensdata,66,4)); $windDirectionText = $winddir_name[$windDirection]; $windDirectionDegree = $windDirection * 360 / 16; - $windSpeed = round(SD_WS09_bin2dec(substr($sensdata,30,16))/240,01); + $windSpeed = FHEM::Core::Utils::Math::round(SD_WS09_bin2dec(substr($sensdata,30,16))/240,01); Log3 $iohash, 4, "$name: SD_WS09_Parse_15 ".$model." Windspeed bit: ".substr($sensdata,32,8)." Dec: " . $windSpeed ; - $windguest = round((SD_WS09_bin2dec(substr($sensdata,40,8)) * 34)/100,01); + $windguest = FHEM::Core::Utils::Math::round((SD_WS09_bin2dec(substr($sensdata,40,8)) * 34)/100,01); Log3 $iohash, 4, "$name: SD_WS09_Parse_16 ".$model." Windguest bit: ".substr($sensdata,40,8)." Dec: " . $windguest ; - $rain = round(SD_WS09_bin2dec(substr($sensdata,46,16)) * 0.3,01); + $rain = FHEM::Core::Utils::Math::round(SD_WS09_bin2dec(substr($sensdata,46,16)) * 0.3,01); Log3 $iohash, 4, "$name: SD_WS09_Parse_17 ".$model." Rain bit: ".substr($sensdata,46,16)." Dec: " . $rain ; } else { Log3 $iohash, 4, "$name: SD_WS09_Parse_18 CTW600 EXIT: msg=$bitData length:".length($bitData) ; @@ -382,31 +383,31 @@ sub SD_WS09_Parse { Log3 $hash, 4, "SD_WS09_Wind $windstat[0] : Faktor:$wfaktor" ; $wfaktor = $uowind_unit{"km/h"}; - $windguest_kmh = round ($windguest * $wfaktor,01); - $windSpeed_kmh = round ($windSpeed * $wfaktor,01); + $windguest_kmh = FHEM::Core::Utils::Math::round ($windguest * $wfaktor,01); + $windSpeed_kmh = FHEM::Core::Utils::Math::round ($windSpeed * $wfaktor,01); $windstat[1]= " Ws:$windSpeed_kmh Wg:$windguest_kmh km/h"; Log3 $hash, 4, "SD_WS09_Wind $windstat[1] : Faktor:$wfaktor" ; $wfaktor = $uowind_unit{"ft/s"}; - $windguest_fts = round ($windguest * $wfaktor,01); - $windSpeed_fts = round ($windSpeed * $wfaktor,01); + $windguest_fts = FHEM::Core::Utils::Math::round ($windguest * $wfaktor,01); + $windSpeed_fts = FHEM::Core::Utils::Math::round ($windSpeed * $wfaktor,01); $windstat[2]= " Ws:$windSpeed_fts Wg:$windguest_fts ft/s"; Log3 $hash, 4, "SD_WS09_Wind $windstat[2] : Faktor:$wfaktor" ; $wfaktor = $uowind_unit{"mph"}; - $windguest_mph = round ($windguest * $wfaktor,01); - $windSpeed_mph = round ($windSpeed * $wfaktor,01); + $windguest_mph = FHEM::Core::Utils::Math::round ($windguest * $wfaktor,01); + $windSpeed_mph = FHEM::Core::Utils::Math::round ($windSpeed * $wfaktor,01); $windstat[3]= " Ws:$windSpeed_mph Wg:$windguest_mph mph"; Log3 $hash, 4, "SD_WS09_Wind $windstat[3] : Faktor:$wfaktor" ; $wfaktor = $uowind_unit{"knot"}; - $windguest_kn = round ($windguest * $wfaktor,01); - $windSpeed_kn = round ($windSpeed * $wfaktor,01); + $windguest_kn = FHEM::Core::Utils::Math::round ($windguest * $wfaktor,01); + $windSpeed_kn = FHEM::Core::Utils::Math::round ($windSpeed * $wfaktor,01); $windstat[4]= " Ws:$windSpeed_kn Wg:$windguest_kn kn" ; Log3 $hash, 4, "SD_WS09_Wind $windstat[4] : Faktor:$wfaktor" ; - $windguest_bft = round(sqrt( 9 + (6 * $windguest)) - 3,0) ; - $windSpeed_bft = round(sqrt( 9 + (6 * $windSpeed)) - 3,0) ; + $windguest_bft = FHEM::Core::Utils::Math::round(sqrt( 9 + (6 * $windguest)) - 3,0) ; + $windSpeed_bft = FHEM::Core::Utils::Math::round(sqrt( 9 + (6 * $windSpeed)) - 3,0) ; $windstat[5]= " Ws:$windSpeed_bft Wg:$windguest_bft bft"; Log3 $hash, 4, "SD_WS09_Wind $windstat[5] " ; @@ -556,7 +557,7 @@ sub SD_WS09_WindDirAverage { my $time = FmtDateTime($ctime); my @new = ($ws,$wd,$time); - Log3 $hash, 4,"SD_WS09_WindDirAverage_01 $name :Speed=".$ws." DirR=".round($wd,2)." Time=".$time; + Log3 $hash, 4,"SD_WS09_WindDirAverage_01 $name :Speed=".$ws." DirR=".FHEM::Core::Utils::Math::round($wd,2)." Time=".$time; Log3 $hash, 4,"SD_WS09_WindDirAverage_02 $name :avtime=".$avtime." decay=".$decay." minspeed=".$minspeed; my $num; @@ -578,16 +579,16 @@ sub SD_WS09_WindDirAverage { $arr=\@{$hash->{helper}{history}}; my $stime = time_str2num($arr->[0][2]); # Zeitpunkt des ältesten Eintrags my $ltime = time_str2num($arr->[$num-1][2]); # Zeitpunkt des letzten Eintrags - Log3 $hash,4,"SD_WS09_WindDirAverage_04 $name :Speed=".$ws." Dir=".round($wd,2)." Time=".$time." minspeed=".$minspeed." ctime=".$ctime." ltime=".$ltime." stime=".$stime." num=".$num; + Log3 $hash,4,"SD_WS09_WindDirAverage_04 $name :Speed=".$ws." Dir=".FHEM::Core::Utils::Math::round($wd,2)." Time=".$time." minspeed=".$minspeed." ctime=".$ctime." ltime=".$ltime." stime=".$stime." num=".$num; if((($ctime - $ltime) > 10) || ($num == 0)) { if(($num < 25) && (($ctime-$stime) < $avtime)){ - Log3 $hash,4,"SD_WS09_WindDirAverage_05 $name :Speed=".$ws." Dir=".round($wd,2)." Time=".$time." minspeed=".$minspeed." num=".$num; + Log3 $hash,4,"SD_WS09_WindDirAverage_05 $name :Speed=".$ws." Dir=".FHEM::Core::Utils::Math::round($wd,2)." Time=".$time." minspeed=".$minspeed." num=".$num; push(@{$hash->{helper}{history}},\@new); } else { shift(@{$hash->{helper}{history}}); push(@{$hash->{helper}{history}},\@new); - Log3 $hash,4,"SD_WS09_WindDirAverage_06 $name :Speed=".$ws." Dir=".round($wd,2)." Time=".$time." minspeed=".$minspeed." num=".$num; + Log3 $hash,4,"SD_WS09_WindDirAverage_06 $name :Speed=".$ws." Dir=".FHEM::Core::Utils::Math::round($wd,2)." Time=".$time." minspeed=".$minspeed." num=".$num; } } else { return $windDirection_old; # old undef | different behavior dispatch <-> UnitTest´s ($ctime - $ltime) @@ -603,7 +604,7 @@ sub SD_WS09_WindDirAverage { $age = $ctime - time_str2num($time); if (($time eq "") || ($age > $avtime)) { #-- zu alte Einträge entfernen - Log3 $hash,4,"SD_WS09_WindDirAverage_07 $name i=".$i." Speed=".round($ws,2)." Dir=".round($wd,2)." Time=".substr($time,11)." ctime=".$ctime." akt.=".time_str2num($time); + Log3 $hash,4,"SD_WS09_WindDirAverage_07 $name i=".$i." Speed=".FHEM::Core::Utils::Math::round($ws,2)." Dir=".FHEM::Core::Utils::Math::round($wd,2)." Time=".substr($time,11)." ctime=".$ctime." akt.=".time_str2num($time); shift(@{$hash->{helper}{history}}); $i--; $num--; @@ -618,11 +619,11 @@ sub SD_WS09_WindDirAverage { $sumSin += sin($wd) * $ws * $weight; $sumCos += cos($wd) * $ws * $weight; $anz++; - Log3 $hash,4,"SD_WS09_WindDirAverage_08 $name i=".$i." Speed=".round($ws,2)." Dir=".round($wd,2)." Time=".substr($time,11)." vec=".round($sumSin,2)."/".round($sumCos,2)." age=".$age." ".round($weight,2); + Log3 $hash,4,"SD_WS09_WindDirAverage_08 $name i=".$i." Speed=".FHEM::Core::Utils::Math::round($ws,2)." Dir=".FHEM::Core::Utils::Math::round($wd,2)." Time=".substr($time,11)." vec=".FHEM::Core::Utils::Math::round($sumSin,2)."/".FHEM::Core::Utils::Math::round($sumCos,2)." age=".$age." ".FHEM::Core::Utils::Math::round($weight,2); } } my $average = int((rad2deg(atan2($sumSin, $sumCos)) + 360) % 360); - Log3 $hash,4,"SD_WS09_WindDirAverage_09 $name Mittelwert über $anz Werte ist $average, avspeed=".round($sumSpeed/$num,1) if ($num > 0); + Log3 $hash,4,"SD_WS09_WindDirAverage_09 $name Mittelwert über $anz Werte ist $average, avspeed=".FHEM::Core::Utils::Math::round($sumSpeed/$num,1) if ($num > 0); #-- undef zurückliefern, wenn die durchschnittliche Geschwindigkeit zu gering oder gar keine Werte verfügbar return if (($anz == 0) || ($sanz == 0)); diff --git a/controls_signalduino.txt b/controls_signalduino.txt index ea118d38d..5d958b707 100644 --- a/controls_signalduino.txt +++ b/controls_signalduino.txt @@ -1,16 +1,16 @@ -UPD 2023-01-16_06:44:58 235986 FHEM/00_SIGNALduino.pm +UPD 2023-01-21_11:20:22 235965 FHEM/00_SIGNALduino.pm UPD 2023-01-06_12:08:43 20082 FHEM/10_FS10.pm UPD 2023-01-09_20:47:40 25008 FHEM/10_SD_GT.pm UPD 2023-01-01_18:10:40 25403 FHEM/10_SD_Rojaflex.pm UPD 2023-01-01_18:10:40 10096 FHEM/14_BresserTemeo.pm UPD 2023-01-01_18:10:40 16260 FHEM/14_FLAMINGO.pm UPD 2023-01-23_18:12:05 24036 FHEM/14_Hideki.pm -UPD 2023-01-09_19:54:48 13206 FHEM/14_SD_AS.pm +UPD 2023-01-21_11:20:22 13260 FHEM/14_SD_AS.pm UPD 2023-01-01_18:10:40 29419 FHEM/14_SD_BELL.pm UPD 2023-01-04_21:24:03 187527 FHEM/14_SD_UT.pm -UPD 2023-01-14_11:57:58 143612 FHEM/14_SD_WS.pm +UPD 2023-01-21_11:20:22 144048 FHEM/14_SD_WS.pm UPD 2023-01-09_19:54:48 21030 FHEM/14_SD_WS07.pm -UPD 2023-01-09_19:54:48 37810 FHEM/14_SD_WS09.pm +UPD 2023-01-21_11:20:22 38569 FHEM/14_SD_WS09.pm UPD 2023-01-09_19:54:48 16458 FHEM/14_SD_WS_Maverick.pm UPD 2023-01-09_19:54:48 40373 FHEM/41_OREGON.pm UPD 2020-12-17_23:16:30 15582 FHEM/90_SIGNALduino_un.pm