Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/github_actions/codecov/codecov-…
Browse files Browse the repository at this point in the history
…action-3.0.0
  • Loading branch information
sidey79 authored Apr 15, 2022
2 parents 7e62d9d + f83d794 commit 96e0ba5
Show file tree
Hide file tree
Showing 11 changed files with 166 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/perlCritic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: shogo82148/actions-setup-perl@v1.14.2
- uses: shogo82148/actions-setup-perl@v1.15.1
with:
perl-version: 5.32
install-modules-with: cpanm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Perl ${{ matrix.perl }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: shogo82148/actions-setup-perl@v1.14.2
- uses: shogo82148/actions-setup-perl@v1.15.1
with:
perl-version: ${{ matrix.perl }}
install-modules-with: cpanm
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ jobs:
find: '\d\.\d\.\d'
include: "${{ matrix.file }}"
- uses: jungwinter/split@v2
name: Split array result
if: ${{ steps.versionList.outputs.fileFoundCount > 0 }}
id: versions
with:
msg: '${{ steps.versionList.outputs.resultArray }}'
Expand All @@ -126,7 +128,7 @@ jobs:
replace: "${{ needs.metadata.outputs.datetime }}Z ${{ github.event.pull_request.user.login }} "
include: "${{ matrix.file }}"
- name: Save updated Files in artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: updated-files
retention-days: 1
Expand All @@ -142,7 +144,7 @@ jobs:
fetch-depth: 0
persist-credentials: false
- name: Download all modified artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
path: ${{ github.workspace }}
- name: replace files from artifacts
Expand Down
12 changes: 12 additions & 0 deletions CHANGED
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
2022-04-15 - Fix wrong calculation of averagewindDirection (#1095)

* Update 14_SD_WS09.pm

- usw CORE Time instead of global from hires
- optimzed code a little bit, removed useless checks
- few perlcritic fixes
2022-04-11 - additional sensors protocol 115 for Bresser 6-in-1 Comfort Wetter Center (#1085)

SD_ProtocolData.pm - fixed packet length 18 byte
14_SD_WS.pm - new ground/earth sensor for humidity and temperature, indoor sensor for humidity and temperature

2022-03-16 - clone Protocol Object for every definition (#1084)

* 00_SIGNALduino.pm
Expand Down
58 changes: 36 additions & 22 deletions FHEM/14_SD_WS.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id: 14_SD_WS.pm 21666 2022-01-30 10:19:30Z elektron-bbs $
# $Id: 14_SD_WS.pm v3.5.4 2022-03-20 10:05:23Z elektron-bbs $
#
# The purpose of this module is to support serval
# weather sensors which use various protocol
Expand Down Expand Up @@ -42,10 +42,11 @@
# 14.01.2022 neues Protokoll 116: Thunder and lightning sensor Fine Offset WH57, aka Froggit DP60, aka Ambient Weather WH31L
# 29.01.2022 neues Protokoll 117: Bresser 7-in-1 Comfort Wetter Center
# 04.02.2022 neu: set replaceBatteryForSec (Ident ersetzen bei Batteriewechsel Sensor)
# 12.03.2022 Protokoll 115: neue Sensoren SM60020 Boden-/Erd-Sensor für Feuchte- und Temperatur, Innensensor für Feuchte- und Temperatur

package main;

#use version 0.77; our $VERSION = version->declare('v3.4.3');
#use version 0.77; our $VERSION = version->declare('v3.5.4');

use strict;
use warnings;
Expand Down Expand Up @@ -219,10 +220,11 @@ sub SD_WS_Parse {
my $uv;
my $adc;
my $brightness;
my @moisture_map=(0, 7, 13, 20, 27, 33, 40, 47, 53, 60, 67, 73, 80, 87, 93, 99); # ID 115
my $count;
my $identified;

my %decodingSubs = (
my %decodingSubs = (
50 => # Protocol 50
# FF550545FF9E
# FF550541FF9A
Expand Down Expand Up @@ -1037,64 +1039,76 @@ sub SD_WS_Parse {
# 0123456789012345678901234567890123456789
# ----------------------------------------
# 3DA820B00C1618FFFFFF1808152294FFF01E0000 Msg 1, 40 Nibble from SIGNALduino, T: 15.2 H: 94 G:0 W: 0 D:180
# CCCCIIIIIIIIFFGGGWWWDDD?TTT?HH????SS Msg 1, 36 Nibble
# CCCCIIIIIIIIFFGGGWWWDDD?ffRRRRVVV?SS Msg 2, 36 Nibble
# CCCCIIIIIIIIFFGGGWWWDDD?TTT?HHVVVXSS Msg 1, 36 Nibble, wind, temperature, humidity, uv
# CCCCIIIIIIIIFFGGGWWWDDD?RRRRRR???XSS Msg 2, 36 Nibble, wind, rain
# C = CRC16
# I = station ID
# F = flags, 4 bit (1: weather station, 2: indoor?, 4: soil probe), 1 bit battery (1=ok, 0=low), 3 bit channel
# F = flags, 4 bit (1: weather station, 2: indoor, 4: soil probe), 1 bit battery (1=ok, 0=low), 3 bit channel
# G = wind gust in 1/10 m/s, inverted, BCD coded, GGG = FE6 =~ 019 => 1.9 m/s.
# W = wind speed in 1/10 m/s, inverted, BCD coded, LSB first nibble, MSB last two nibble, WWW = EFE =~ 101 => 1.1 m/s.
# D = wind direction in grad, BCD coded, DDD = 158 => 158 °
# ? = unknown, always 0x8
# T = temperature in 1/10 °C, only if byte 12 ne 0xFF, BCD coded, TTT = 312 => 31.2 °C
# ? = unknown
# H = humidity in percent, only if byte 12 ne 0xFF, BCD coded, HH = 23 => 23 %
# R = rain counter, only if byte 12 eq 0xFF, inverted, BCD coded
# V = uv, only if byte 12 eq 0xFF and byte 15/16 not 0xFF01, inverted, BCD coded
# ? = unknown
# ? = unknown, 0x0, 0x8 or 0xE
# T = temperature in 1/10 °C, TTT = 312 => 31.2 °C
# ? = unknown, 0x2, 0x4, 0x6 or 0xF
# H = humidity in percent, BCD coded, HH = 23 => 23 %
# R = rain counter, inverted, BCD coded
# V = uv, inverted, BCD coded
# X = message type, 0 = temp, hum, wind, uv, 1 = wind, rain
# S = checksum (sum over byte 2 - 17 must be 255)
sensortype => 'Bresser_6in1, new Bresser_5in1',
model => 'SD_WS_115',
prematch => sub { return 1; }, # no precheck known
id => sub {my ($rawData,undef) = @_; return substr($rawData,4,8); },
bat => sub {my (undef,$bitData) = @_; return substr($bitData,52,1) eq '1' ? 'ok' : 'low';},
channel => sub {my (undef,$bitData) = @_; return (SD_WS_binaryToNumber($bitData,53,55));},
channel => sub {my ($rawData,$bitData) = @_;
$channel = '';
$channel = substr($rawData,12,1) if (substr($rawData,12,1) ne '1'); # not weather station
return ($channel . SD_WS_binaryToNumber($bitData,53,55));
},
windgust => sub {my ($rawData,undef) = @_;
return if (substr($rawData,12,1) ne '1'); # only weather station
$windgust = substr($rawData,14,3);
$windgust =~ tr/0123456789ABCDEF/FEDCBA9876543210/;
return if ($windgust !~ m/^\d+$/xms);
return $windgust * 0.1;
},
windspeed => sub {my ($rawData,undef) = @_;
return if (substr($rawData,12,1) ne '1'); # only weather station
$windspeed = substr($rawData,18,2) . substr($rawData,17,1);
$windspeed =~ tr/0123456789ABCDEF/FEDCBA9876543210/;
return if ($windspeed !~ m/^\d+$/xms);
return $windspeed * 0.1;
},
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 if ($winddir !~ m/^\d+$/xms);
return ($winddir * 1, $winddirtxtar[round(($winddir / 22.5),0)]);
},
temp => sub {my ($rawData,undef) = @_;
return if (substr($rawData,24,2) eq 'FF');
$rawTemp = (substr($rawData,24,1) . substr($rawData,25,1) . substr($rawData,26,1)) * 0.1;
return if (substr($rawData,33,1) ne '0' || substr($rawData,24,3) !~ m/^\d+$/xms);
$rawTemp = substr($rawData,24,3) * 0.1;
if ($rawTemp > 60) {$rawTemp -= 100};
return $rawTemp;
},
hum => sub {my ($rawData,undef) = @_;
return if (substr($rawData,24,2) eq 'FF');
return substr($rawData,28,2) + 0;
return if (substr($rawData,33,1) ne '0' || substr($rawData,28,2) !~ m/^\d+$/xms);
$hum = substr($rawData,28,2) * 1;
if (substr($rawData,12,1) eq '4' && $hum >= 1 && $hum <= 16) { # Soil Moisture
return $moisture_map[$hum - 1];
}
return $hum;
},
rain => sub {my ($rawData,undef) = @_;
return if (substr($rawData,24,2) ne 'FF');
$rain = substr($rawData,26,4);
return if (substr($rawData,33,1) ne '1' || substr($rawData,12,1) ne '1'); # only weather station
$rain = substr($rawData,24,6);
$rain =~ tr/0123456789ABCDEF/FEDCBA9876543210/;
return if ($rain !~ m/^\d+$/xms);
return $rain * 0.1;
},
uv => sub {my ($rawData,undef) = @_;
return if (substr($rawData,24,2) ne 'FF' || substr($rawData,30,3) !~ m/^\d+$/xms);
return if (substr($rawData,33,1) ne '0' || substr($rawData,12,1) ne '1'); # only weather station
$uv = substr($rawData,30,3);
$uv =~ tr/0123456789ABCDEF/FEDCBA9876543210/;
return if ($uv !~ m/^\d+$/xms);
return $uv * 0.1;
},
Expand Down
65 changes: 35 additions & 30 deletions FHEM/14_SD_WS09.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##############################################
# $Id: 14_SD_WS09.pm 21622 2021-08-10 19:51:16Z sidey79 $
# $Id: 14_SD_WS09.pm 3.5.4 2022-04-15 16:51:07Z sidey79 $
#
# The purpose of this module is to support serval
# weather sensors like WS-0101 (Sender 868MHz ASK Epmfänger RX868SH-DV elv)
Expand Down Expand Up @@ -488,7 +488,7 @@ sub SD_WS09_Attr(@) {
}

###################################
sub SD_WS09_WindDirAverage($$$){
sub SD_WS09_WindDirAverage {
###############################################################################
# übernommen von SabineT https://forum.fhem.de/index.php/topic,75225.msg669950.html#msg669950
# WindDirAverage
Expand All @@ -513,6 +513,11 @@ sub SD_WS09_WindDirAverage($$$){
###############################################################################

my ($hash, $ws, $wd) = @_;

return if ref($hash) ne 'HASH';
return if !defined $ws;
return if !defined $wd;

my $name = $hash->{NAME};
Log3 $hash, 4, "SD_WS09_WindDirAverage --- OK ----" ;

Expand All @@ -531,20 +536,20 @@ sub SD_WS09_WindDirAverage($$$){
return "";
}

my $avtime = AttrVal($name,'WindDirAverageTime',0);
my $avtime = AttrVal($name,'WindDirAverageTime',600);
my $decay = AttrVal($name,'WindDirAverageDecay',0);
my $minspeed = AttrVal($name,'WindDirAverageMinSpeed',0);
my $windDirection_old = $wd;

# default Werte für die optionalen Parameter, falls nicht beim Aufruf mit angegeben
$avtime = 600 if (!(defined $avtime) || $avtime == 0 );
#$avtime = 600 if (!(defined $avtime) || $avtime == 0 );
$decay = 1 if (!(defined $decay));
$decay = 1 if ($decay > 1); # darf nicht >1 sein
$decay = 0 if ($decay < 0); # darf nicht <0 sein
$minspeed = 0 if (!(defined $minspeed));
#$minspeed = 0 if (!(defined $minspeed));

$wd = deg2rad($wd);
my $ctime = time;
my $ctime = CORE::time;
my $time = FmtDateTime($ctime);
my @new = ($ws,$wd,$time);

Expand Down Expand Up @@ -590,38 +595,38 @@ sub SD_WS09_WindDirAverage($$$){
my ($anz, $sanz) = 0;
$num = int(@{$hash->{helper}{history}});
my ($sumSin, $sumCos, $sumSpeed, $age, $maxage, $weight) = 0;
for(my $i=0; $i<$num; $i++){
for(my $i=0; $i<$num; $i++) {
($ws, $wd, $time) = @{ $arr->[$i] };
$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);
shift(@{$hash->{helper}{history}});
$i--;
$num--;
} else {
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);
shift(@{$hash->{helper}{history}});
$i--;
$num--;
} else {
#-- Werte aufsummieren, Windrichtung gewichtet über Geschwindigkeit und decay/"alter"
$weight = $decay ** ($age / $avtime);
#-- für die Mittelwertsbildung der Geschwindigkeit wird nur ein 10tel von avtime genommen
if ($age < ($avtime / 10)) {
$sumSpeed += $ws * $weight if ($age < ($avtime / 10));
$sanz++;
}
$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);
}
}
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);
$weight = $decay ** ($age / $avtime);
#-- für die Mittelwertsbildung der Geschwindigkeit wird nur ein 10tel von avtime genommen
if ($age < ($avtime / 10)) {
$sumSpeed += $ws * $weight ;
$sanz++;
}
$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);
}
}
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);

#-- undef zurückliefern, wenn die durchschnittliche Geschwindigkeit zu gering oder gar keine Werte verfügbar
return undef if (($anz == 0) || ($sanz == 0));
return undef if (($sumSpeed / $sanz) < $minspeed);
return if (($anz == 0) || ($sanz == 0));
return if (($sumSpeed / $sanz) < $minspeed);

Log3 $hash,4,"SD_WS09_WindDirAverage_END $name Mittelwert=$average";
return $average;
Log3 $hash,4,"SD_WS09_WindDirAverage_END $name Mittelwert=$average";
return $average;
}

###################################
Expand Down
6 changes: 3 additions & 3 deletions FHEM/lib/SD_ProtocolData.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###########################################################################################################################################
# $Id: SD_ProtocolData.pm 3.5.x 2022-01-30 10:19:30Z elektron-bbs $
# $Id: SD_ProtocolData.pm 3.5.4 2022-03-20 10:05:23Z elektron-bbs $
# The file is part of the SIGNALduino project.
# All protocol definitions are contained in this file.
#
Expand Down Expand Up @@ -3070,11 +3070,11 @@ package lib::SD_ProtocolData;
comment => 'BRESSER 6-in-1 weather center',
id => '115',
knownFreqs => '868.35',
datarate => '8.207',
datarate => '8.232',
sync => '2DD4',
modulation => '2-FSK',
rfmode => 'Bresser_6in1',
register => ['0001','0246','0344','042D','05D4','06FF','07C0','0802','0D21','0E65','0FE8','1088','114C','1202','1322','14F8','1551','1916','1B43','1C68'],
register => ['0001','022E','0344','042D','05D4','0612','07C0','0800','0D21','0E65','0FE8','1088','114C','1202','1322','14F8','1551','1916','1B43','1C68'],
preamble => 'W115#',
clientmodule => 'SD_WS',
length_min => '36',
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Supported Devices / Protocols
|BF-301 | Remote control|
|benon (Semexo OHG) | Remote control (BH-P)|
|BOSCH / Neff / Refsta Topdraft | Remote control (SF01 01319004, SF01 01319004 v2)|
|BRESSER 5-in-1, 6-in-1, 7-in-1, Professional Rain Gauge, TemeoTrend | Weather Station, Rain Gauge, Thermo-/Hygro Sensor |
|BRESSER 5-in-1, 6-in-1, 7-in-1, Professional Rain Gauge, TemeoTrend, SM60020 Soil moisture sensor | Weather Station, Rain Gauge, Thermo-/Hygro Sensor |
|CAME TOP 432EV | Remote control |
|CTW600, WH1080, WH2315 | Weather station |
|Clarus | remote power socket|
Expand Down
6 changes: 3 additions & 3 deletions controls_signalduino.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ UPD 2022-01-25_17:15:17 19373 FHEM/14_Hideki.pm
UPD 2020-10-03_11:48:15 11170 FHEM/14_SD_AS.pm
UPD 2021-07-13_20:29:34 29223 FHEM/14_SD_BELL.pm
UPD 2022-03-06_20:47:38 173345 FHEM/14_SD_UT.pm
UPD 2022-02-18_15:37:22 120360 FHEM/14_SD_WS.pm
UPD 2022-04-11_18:36:13 121527 FHEM/14_SD_WS.pm
UPD 2021-12-30_17:02:10 18709 FHEM/14_SD_WS07.pm
UPD 2021-08-11_21:38:30 35313 FHEM/14_SD_WS09.pm
UPD 2022-04-15_20:58:20 35384 FHEM/14_SD_WS09.pm
UPD 2020-04-13_23:15:56 14325 FHEM/14_SD_WS_Maverick.pm
UPD 2021-08-11_21:38:30 37904 FHEM/41_OREGON.pm
UPD 2020-12-17_23:16:30 15582 FHEM/90_SIGNALduino_un.pm
UPD 2022-03-07_20:25:23 228539 FHEM/lib/SD_ProtocolData.pm
UPD 2022-04-11_18:36:13 228539 FHEM/lib/SD_ProtocolData.pm
UPD 2022-03-07_20:25:23 75991 FHEM/lib/SD_Protocols.pm
Loading

0 comments on commit 96e0ba5

Please sign in to comment.