hobbyquaker / cul

nodejs module to interact with busware cul / culfw
GNU General Public License v2.0
26 stars 21 forks source link

Add support for KS300 weather station #27

Open tetzlav opened 4 years ago

tetzlav commented 4 years ago

The messages of KS300 are nearly the same as S300TH + rain and wind info: https://github.com/mhop/fhem-mirror/blob/master/fhem/FHEM/13_KS300.pm

Please add support for KS300TH...

tetzlav commented 3 years ago

I think it would be enough to support the elementary parse of data. The modul 13_KS300.pm does unnecessary stuff.

The raw data the station send eg.: RAW: K1756610500A3E0DD

But i dont really understand the perl code (https://github.com/mhop/fhem-mirror/blob/master/fhem/FHEM/14_CUL_WS.pm; 280ff):

    } elsif(@a == 15 && int(@a) > 14) {          # KS300/2
      my $c = $hash->{corr4} ? $hash->{corr4} : 255;
      $rain = sprintf("%0.1f", hex("$a[14]$a[11]$a[12]") * $c / 1000);
      $wnd  = sprintf("%0.1f", "$a[9]$a[10].$a[7]" + $hash->{corr3});
      $hum  = sprintf( "%02d", "$a[8]$a[5]" + $hash->{corr2});
      $tmp  = sprintf("%0.1f", ("$a[6]$a[3].$a[4]"+ $hash->{corr1}),
                             (($a[1] & 0xC) ? -1 : 1));
      my $ir = ((hex($a[1]) & 2)) ? "yes" : "no";

      $val = "T: $tmp  H: $hum  W: $wnd  R: $rain  IR: $ir";
      $devtype = "KS300/2";
      $family = "WS300";
      $NotifyType="T H W R IR";
      $NotifyTemperature=$tmp;
      $NotifyHumidity=$hum;
      $NotifyWind=$wnd;
      $NotifyRain=$rain;
      $NotifyIsRaining=$ir;

Why compare an array with an integer? Perl...!?

And i also dont understand the javascript in https://github.com/hobbyquaker/cul/blob/master/lib/ws.js.