@Willi : request to patch files to support some X10 sensors

Begonnen von oliv06, 13 April 2016, 00:30:35

Vorheriges Thema - Nächstes Thema

oliv06

Hello Willi, some times ago you accepted to include some of my patches (eg Chacon ring, Somfy RTS support) but my requests for other patches remained without an answer. Could you please consider them because it is quite time consuming to patch each time there is a change in the SVN repository.

I wrote a post on my blog to detail supported X10 sensors and patched files are on github

Thanks a lot !

45_TRX.pm
Zitatdiff -up 45_TRX.pm.2016-02-12  45_TRX.pm
--- 45_TRX.pm.2016-02-12    2016-04-12 21:29:32.295746720 +0200
+++ 45_TRX.pm    2016-04-12 21:38:12.905657991 +0200
@@ -24,7 +24,7 @@
# The GNU General Public License may also be found at http://www.gnu.org/licenses/gpl-2.0.html .
#
###########################
-# $Id: 45_TRX.pm 10802 2016-02-12 19:41:38Z wherzig $
+# $Id: 45_TRX.pm 10802 2016-02-12 19:41:38Z wherzig - modified oliv06$
package main;

use strict;
@@ -58,10 +58,10 @@ TRX_Initialize($)
   $hash->{Clients} =
         ":TRX_WEATHER:TRX_SECURITY:TRX_LIGHT:TRX_ELSE:";
   my %mc = (
-    "1:TRX_WEATHER"       => "^..(4e|50|51|52|54|55|56|57|58|5a|5b|5c|5d).*",
+    "1:TRX_WEATHER"       => "^..(40|4e|50|51|52|54|55|56|57|58|5a|5b|5c|5d).*",
     "2:TRX_SECURITY"     => "^..(20).*",
     "3:TRX_LIGHT"    => "^..(10|11|12|13|14|15|16|17|18|19).*",
-    "4:TRX_ELSE"       => "^..(0[0-9a-f]|1[a-f]|2[1-9a-f]|3[0-9a-f]|4[0-9a-d]|4f|53|59|5e|5f|[6-9a-f][0-9a-f]).*",
+    "4:TRX_ELSE"       => "^..(0[0-9a-f]|1[a-f]|2[1-9a-f]|3[0-9a-f]|4[1-9a-d]|4f|53|59|5e|5f|[6-9a-f][0-9a-f]).*",
   );
   $hash->{MatchList} = \%mc;

46_TRX_ELSE.pm
Zitatdiff -up 46_TRX_ELSE.pm.2016-02-13 46_TRX_ELSE.pm
--- 46_TRX_ELSE.pm.2016-02-13    2016-04-12 21:52:20.157782675 +0200
+++ 46_TRX_ELSE.pm    2016-04-12 21:54:14.755990648 +0200
@@ -26,7 +26,7 @@
# 4: log unknown protocols
# 5: log decoding hexlines for debugging
#
-# $Id: 46_TRX_ELSE.pm 10814 2016-02-13 12:56:21Z wherzig $
+# $Id: 46_TRX_ELSE.pm 10814 2016-02-13 12:56:21Z wherzig - modified oliv06$
package main;

use strict;
@@ -41,7 +41,7 @@ TRX_ELSE_Initialize($)
{
   my ($hash) = @_;

-  $hash->{Match}     = "^..(0[0-9a-f]|1[a-f]|2[1-9a-f]|3[0-9a-f]|4[0-9a-d]|4f|53|59|5e|5f|[6-9a-f][0-9a-f]).*";
+  $hash->{Match}     = "^..(0[0-9a-f]|1[a-f]|2[1-9a-f]|3[0-9a-f]|4[1-9a-d]|4f|53|59|5e|5f|[6-9a-f][0-9a-f]).*";
   $hash->{DefFn}     = "TRX_ELSE_Define";
   $hash->{UndefFn}   = "TRX_ELSE_Undef";
   $hash->{ParseFn}   = "TRX_ELSE_Parse";

46_TRX_SECURITY
Zitat
diff -up 46_TRX_SECURITY.pm.original 46_TRX_SECURITY.pm
--- 46_TRX_SECURITY.pm.original    2016-04-12 23:40:22.783667054 +0200
+++ 46_TRX_SECURITY.pm    2016-04-12 21:57:28.503990831 +0200
@@ -1,4 +1,4 @@
-# $Id$
+#
##############################################################################
#
#     46_TRX_SECURITY.pm
@@ -238,14 +238,14 @@ TRX_SECURITY_Define($$)
   $type = uc($type);

   my $my_type;
-  if ($type eq "WD18" || $type eq "GD18" ) {
+  if ($type eq "WD18" || $type eq "GD18" || $type eq "SD18" || $type eq "COD18" || $type eq "GB10E" ) {
     $my_type = "DS10A"; # device will be received as DS10A   
   } else {
     $my_type = $type;
   }
   my $device_name = "TRX".$DOT.$my_type.$DOT.$deviceid;

-  if ($type ne "DS10A" && $type ne "SD90" && $type ne "MS10A" && $type ne "MS14A" && $type ne "KR18" && $type ne "KD101" && $type ne "VISONIC_WINDOW" && $type ne "VISONIC_MOTION" && $type ne "VISONIC_WINDOW_AUX" && $type ne "VISONIC_REMOTE" && $type ne "MEIANTECH" && $type ne "SA30" && $type ne "GD18" && $type ne "WD18") {
+  if ($type ne "DS10A" && $type ne "SD90" && $type ne "MS10A" && $type ne "MS14A" && $type ne "KR18" && $type ne "KD101" && $type ne "VISONIC_WINDOW" && $type ne "VISONIC_MOTION" && $type ne "VISONIC_WINDOW_AUX" && $type ne "VISONIC_REMOTE" && $type ne "MEIANTECH" && $type ne "SA30" && $type ne "GD18" && $type ne "WD18" && $type ne "SD18" && $type ne "COD18" && $type ne "GB10E") {
       Log3 $hash, 1,"TRX_SECURITY_Define() wrong type: $type";
       return "TRX_SECURITY: wrong type: $type";
   }
@@ -601,6 +601,7 @@ TRX_SECURITY_Parse($$)
       specifies one of the following security devices:
         <ul>
           <li> <code>DS10A</code> (X10 security ds10a Door/Window Sensor or compatible devices. This device type reports the status of the switch [Open/Closed], status of the delay switch [min|max]], and battery status [ok|low].)</li>
+          <li> <code>SD18</code> or <code>COD18</code>(X10 security sd18 smoke Sensor and COD18 CO Sensor). These device types report the status of the sensor [alert/normal] and battery status [ok|low])</li>
           <li> <code>MS10A</code> (X10 security ms10a motion sensor. This device type reports the status of motion sensor  [normal|alert] and battery status [ok|low].))</li>
           <li> <code>SD90</code> (Marmitek sd90 smoke detector. This device type reports the status of the smoke detector [normal|alert] and battery status [ok|low].)</li>
           <li> <code>KR18</code> (X10 security remote control. Report the Reading "Security" with values [Arm|Disarm], "ButtonA" and "ButtonB" with values [on|off] )</li>
@@ -617,7 +618,7 @@ TRX_SECURITY_Parse($$)
     <br>
     <code>&lt;devicelog&gt;</code>
     <ul>
-    is the name of the Reading used to report. Suggested: "Window" or "Door" for ds10a, "motion" for motion sensors, "smoke" for sd90. If you use "none" then no additional Reading is reported. Just the state is used to report the change.
+    is the name of the Reading used to report. Suggested: "Window" or "Door" for ds10a, "motion" for motion sensors, "smoke" for sd90, sd18 and cod18. If you use "none" then no additional Reading is reported. Just the state is used to report the change.
     </ul>
     <br>
     <code>&lt;deviceid2&gt;</code>

46_TRX_WEATHER.pm

Zitatdiff -up 46_TRX_WEATHER.pm.2016-02-11 46_TRX_WEATHER.pm
--- 46_TRX_WEATHER.pm.2016-02-11    2016-04-12 21:59:59.250580177 +0200
+++ 46_TRX_WEATHER.pm    2016-04-12 22:27:28.976216062 +0200
@@ -1,4 +1,4 @@
-# $Id: 46_TRX_WEATHER.pm 10798 2016-02-11 22:29:43Z wherzig $
+# $Id: 46_TRX_WEATHER.pm 10798 2016-02-11 22:29:43Z wherzig - modified oliv06$
##############################################################################
#
# 46_TRX_WEATHER.pm
@@ -6,6 +6,9 @@
#
# The following devices are implemented to be received:
#
+# thermostats (THERMOSTAT):
+# * "TH10"      is XDOM TH10
+# * "TLX7506"   is Digimax TLX7506
# temperature sensors (TEMP):
# * "THR128"     is THR128/138, THC138
# * "THGR132N"     is THC238/268,THN132,THWR288,THRN122,THN122,AW129/131
@@ -128,7 +131,7 @@ TRX_WEATHER_Initialize($)
{
   my ($hash) = @_;

-  $hash->{Match}     = "^..(4e|50|51|52|54|55|56|57|58|5a|5c|5d).*";
+  $hash->{Match}     = "^..(40|4e|50|51|52|54|55|56|57|58|5a|5c|5d).*";
   $hash->{DefFn}     = "TRX_WEATHER_Define";
   $hash->{UndefFn}   = "TRX_WEATHER_Undef";
   $hash->{ParseFn}   = "TRX_WEATHER_Parse";
@@ -183,6 +186,8 @@ TRX_WEATHER_Undef($$)

my %types =
   (
+   # THERMOSTAT
+   0x4009 => { part => 'THERMOSTAT', method => \&TRX_WEATHER_common_therm, },
    # BBQ
    0x4e0a => { part => 'BBQ', method => \&TRX_WEATHER_common_bbq, },
    # TEMP
@@ -526,6 +531,100 @@ sub TRX_WEATHER_common_bbq {
   return @res;
}

+# -----------------------------
+sub TRX_WEATHER_common_therm {
+  my $type = shift;
+  my $longids = shift;
+  my $bytes = shift;
+
+  my $subtype = sprintf "%02x", $bytes->[1];
+  my $dev_type;
+
+  my %devname =
+    (   # HEXSTRING => "NAME"
+        0x00 => "TLX7506",
+        0x01 => "TH10",
+  );
+
+  if (exists $devname{$bytes->[1]}) {
+        $dev_type = $devname{$bytes->[1]};
+  } else {
+        Log3 undef, 3, "TRX_WEATHER: common_therm error undefined subtype=$subtype";
+        my @res = ();
+        return @res;
+  }
+
+  #my $seqnbr = sprintf "%02x", $bytes->[2];
+
+  my $dev_str = $dev_type;
+  if (TRX_WEATHER_use_longid($longids,$dev_type)) {
+        $dev_str .= $DOT.sprintf("%02x", $bytes->[3]);
+  }
+  if ($bytes->[4] > 0) {
+        $dev_str .= $DOT.sprintf("%d", $bytes->[4]);
+  }
+
+  my @res = ();
+
+  # hexline debugging
+  if ($TRX_HEX_debug) {
+    my $hexline = ""; for (my $i=0;$i<@$bytes;$i++) { $hexline .= sprintf("%02x",$bytes->[$i]);}
+    push @res, { device => $dev_str, type => 'hexline', current => $hexline, units => 'hex', };
+  }
+
+  #TRX_WEATHER_temperature($bytes, $dev_str, \@res, 5);
+  #TRX_WEATHER_simple_battery($bytes, $dev_str, \@res, 7);
+
+  my $temp = ($bytes->[5]);
+  if ($temp) {
+    push @res, {
+        device => $dev_str,
+        type => 'temp',
+        current => $temp,
+        units => 'Grad Celsius'
+    }
+  }
+
+  my $setpoint =($bytes->[6]);
+  if ($setpoint) {
+      push @res, {
+                device => $dev_str,
+                type => 'setpoint',
+                current => $setpoint,
+                units => 'Grad Celsius'
+        }
+  }
+
+  my $demand;
+  my $t_status = ($bytes->[7] & 0x03);
+  if ($t_status == 0) { $demand = 'n/a'}
+  elsif ($t_status == 1) { $demand = 'on'}
+  elsif ($t_status == 2) { $demand = 'off'}
+  elsif ($t_status == 3) { $demand = 'initializing'}
+  else {
+        $demand = sprintf("unknown-%02x",$t_status);
+  }
+
+  Log3 undef, 5, "TRX_WEATHER: demand = $bytes->[7] $t_status $demand";
+  push @res, {
+        device => $dev_str,
+        type => 'demand',
+        current => sprintf("%s",$demand),
+  };
+
+  #my $t_mode = ($bytes->[7] & 0x01);
+
+  my $rssi = ($bytes->[8] & 0xf0) >> 4;
+
+  if ($trx_rssi == 1) {
+        push @res, {
+                device => $dev_str,
+                type => 'rssi',
+                current => sprintf("%d",$rssi),
+        };
+  }
+  return @res;
+}

# --------------------------------------------------------------------
# T R X _ W E A T H E R _ c o m m o n _ t e m p
@@ -1647,6 +1746,25 @@ TRX_WEATHER_Parse($$)
             $sensor = "time";           
             readingsBulkUpdate($def, $sensor, $i->{current});
     }
+        elsif ($i->{type} eq "setpoint") {
+                        Log3 $name, 5, "TRX_WEATHER: name=$name device=$device_name setpoint ".$i->{current}." ".$i->{units};
+                        $val .= "SP: ".$i->{current}." ";
+
+                        $sensor = "setpoint";
+                        readingsBulkUpdate($def, $sensor, $i->{current});
+        }
+        elsif ($i->{type} eq "demand") {
+                        Log3 $name, 5, "TRX_WEATHER: name=$name device=$device_name state ".$i->{current};
+                        if ($val eq "") {
+                                $val = "$i->{current}";
+                        }
+                        else {
+                                $val .= "D: ".$i->{current}." ";
+                        }
+
+                        $sensor = "demand";
+                        readingsBulkUpdate($def, $sensor, $i->{current});
+        }
     else {
         Log3 $name, 1, "TRX_WEATHER: name=$name device=$device_name UNKNOWN Type: ".$i->{type}." Value: ".$i->{current}
     }
@@ -1710,6 +1828,8 @@ TRX_WEATHER_Parse($$)
     "TFA_WIND" (for TFA wind sensor),<br>
     "BWR101" (for Oregon Scientific BWR101),<br>
     "GR101" (for Oregon Scientific GR101)
+        "TLX7506" (for Digimax TLX7506),<br>
+        "TH10" (for Digimax with short format),<br>
     </ul>
     <br>
     Example: <br>

Willi

Thanks Olivier!

I have now added you changes to SVN. Please look if everything ist there.

Greetings

Willi
FHEM@Q600(debian) mit DS9490R (1Wire) | FHEM@Sheevaplug(debian) mit RFXCOM-Receiver(80002), CULv3 & USB-WDE1 | FHEM@odroid mit CULv2 & RFXtrx433

oliv06

Zitat von: Willi am 15 Mai 2016, 21:08:27
I have now added you changes to SVN. Please look if everything ist there.
Thanks Willi
Everything seems ok.