Skip to content

Commit

Permalink
Modul 14_SIGNALduino_ID7.pm etwas überarbeitet und in 00_SIGNALduino.…
Browse files Browse the repository at this point in the history
…pm als Empfänger aufgenommen.
  • Loading branch information
sidey79 committed Sep 16, 2015
1 parent 184a61e commit c9e79bf
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 78 deletions.
2 changes: 2 additions & 0 deletions FHEM/00_SIGNALduino.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ my $clientsSIGNALduino = ":IT:"
."SIGNALduino_AS:"
."SIGNALduino_un:"
."Cresta:"
."SIGNALduino_ID7:"
;

## default regex match List for dispatching message to logical modules, can be updated during runtime because it is referenced
Expand All @@ -80,6 +81,7 @@ my %matchListSIGNALduino = (
# "7:SIGNALduino_ARC" => "AR.*\$", #ARC protocol switches like IT selflearn
"8:SIGNALduino_un" => "u.*",
"9:Cresta" => "^[5][0|8]75[A-F0-9]+",
"10:SIGNALduino_ID7" => "^u7[A-F0-9]+",
);

#protoID[0]=(s_sigid){-4,-8,-18,500,0,twostate}; // Logi
Expand Down
153 changes: 82 additions & 71 deletions FHEM/14_SIGNALduino_ID7.pm
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
##############################################
# From dancer0705
#
# Receive temperature sensor
# Supported models:
#
#
# Unsupported models are saved in a device named CUL_TCM97001_Unknown
#
# Copyright (C) 2015 Bjoern Hempel
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
#
##############################################
# $Id: 14_SIGNALduino_ID7.pm 2015-09-16 $
#
# The purpose of this module is to support serval
# weather sensors like eas8007
# S. Butzek & Ralf9 2015
#

package main;

Expand All @@ -49,7 +30,7 @@ SIGNALduino_ID7_Initialize($)
{
my ($hash) = @_;

$hash->{Match} = "u.*";
$hash->{Match} = "^u7[a-F0-9]+"; ## Muss noch mal überarbeitet werden, wenn wir mehr über die Sensoren wissen
$hash->{DefFn} = "SIGNALduino_ID7_Define";
$hash->{UndefFn} = "SIGNALduino_ID7_Undef";
$hash->{ParseFn} = "SIGNALduino_ID7_Parse";
Expand All @@ -70,14 +51,20 @@ SIGNALduino_ID7_Define($$)

Log3 "SIGNALduino", 3, "SIGNALduino_ID7_Define $def";

return "wrong syntax: define <name> SIGNALduino_ID7 <code>"
return "wrong syntax: define <name> SIGNALduino_ID7 <code> <minsecs> <equalmsg>".int(@a)
if(int(@a) < 3 || int(@a) > 5);

$hash->{CODE} = $a[2];

$hash->{minsecs} = ((int(@a) > 3) ? $a[3] : 30);
$hash->{equalMSG} = ((int(@a) > 4) ? $a[4] : 0);
$hash->{lastMSG} = "";
$hash->{bitMSG} = "";

$modules{SIGNALduino_ID7}{defptr}{$a[2]} = $hash;
$hash->{STATE} = "Defined";

AssignIoPort($hash);
return undef;
}

Expand All @@ -99,6 +86,7 @@ SIGNALduino_ID7_Parse($$)
{
my ($hash, $msg) = @_;
my $rawData = substr($msg, 2);
my $name = $hash->{NAME};

my $model = "EAS800z";

Expand Down Expand Up @@ -131,61 +119,91 @@ SIGNALduino_ID7_Parse($$)

#print Dumper($modules{SIGNALduino_ID7}{defptr});

my $def = $modules{SIGNALduino_ID7}{defptr}{$id};
my $def = $modules{SIGNALduino_ID7}{defptr}{$hash->{NAME} . "." . $deviceCode};
$def = $modules{SIGNALduino_ID7}{defptr}{$deviceCode} if(!$def);

Log3 $hash, 3, 'SIGNALduino_ID7: ' . $def->{NAME} . ' ' . $id;

if(!$def) {
Log3 $hash, 1, 'SIGNALduino_ID7: UNDEFINED sensor ' . $model . ' detected, code ' . $deviceCode . ' name ' . $hash->{NAME};
return "UNDEFINED SIGNALduino_ID7 $deviceCode";
Log3 $hash, 1, 'SIGNALduino_ID7: UNDEFINED sensor ' . $model . ' detected, code ' . $deviceCode . ' name ' . $hash->{NAME};
return "UNDEFINED SIGNALduino_ID7 $deviceCode";
}

$hash = $def;
$name = $hash->{NAME};
Log3 $name, 4, "SIGNALduino_ID7: $name ($rawData)";

if($hash->{lastReceive} && (time() - $hash->{lastReceive} < $def->{minsecs} )) {
if (($def->{lastMSG} ne $rawData) && ($def->{equalMSG} > 0)) {
Log3 $name, 4, "SIGNALduino_ID7: $name: $deviceCode no skipping due unequal message even if to short timedifference";
} else {
Log3 $name, 4, "SIGNALduino_ID7: $name: $deviceCode Skipping due to short timedifference";
return "";
}
}
$hash->{lastReceive} = time();
$def->{lastMSG} = $rawmsg;
$def->{bitMSG} = $bitData;

my $state = "T: $temp H: $hum";

readingsBeginUpdate($def);
readingsBulkUpdate($def, "state", $state);
readingsBulkUpdate($def, "temperature", $temp);
readingsBulkUpdate($def, "humidity", $hum);
readingsBulkUpdate($def, "battery", $bat);
readingsEndUpdate($def, 1); # Notify is done by Dispatch
readingsBeginUpdate($hash);
readingsBulkUpdate($hash, "state", $state);
readingsBulkUpdate($hash, "temperature", $temp) if ($temp ne"");
readingsBulkUpdate($hash, "humidity", $hum) if ($hum ne "");
readingsBulkUpdate($hash, "battery", $bat) if ($bat ne "");
readingsBulkUpdate($hash, "channel", $channel) if ($channel ne "");

readingsEndUpdate($hash, 1); # Notify is done by Dispatch

}

return undef;
}


SIGNALduino_ID7_Attr(@)
{
my @a = @_;

# Make possible to use the same code for different logical devices when they
# are received through different physical devices.
return if($a[0] ne "set" || $a[2] ne "IODev");
my $hash = $defs{$a[1]};
my $iohash = $defs{$a[3]};
my $cde = $hash->{CODE};
delete($modules{SIGNALduino_ID7}{defptr}{$cde});
$modules{SIGNALduino_ID7}{defptr}{$iohash->{NAME} . "." . $cde} = $hash;
return undef;
}


1;


=pod
=begin html
<a name="CUL_TCM97001"></a>
<h3>CUL_TCM97001</h3>
<a name="Wether Sensors protocol #7"></a>
<h3>Wether Sensors protocol #7</h3>
<ul>
The CUL_TCM97001 module interprets temperature sensor messages received by a Device like CUL, CUN, SIGNALduino etc.<br>
The SIGNALduino_ID7 module interprets temperature sensor messages received by a Device like CUL, CUN, SIGNALduino etc.<br>
<br>
<b>Supported models:</b>
<ul>
<li>TCM97...</li>
<li>ABS700</li>
<li>TCM21....</li>
<li>Prologue</li>
<li>Rubicson</li>
<li>NC_WS</li>
<li>GT-WT-02</li>
<li>AURIOL</li>
<li>EAS800z</li>
</ul>
<br>
New received device packages are add in fhem category CUL_TCM97001 with autocreate.
New received device packages are add in fhem with autocreate.
<br><br>
<a name="CUL_TCM97001_Define"></a>
<a name="SIGNALduino_ID7_Define"></a>
<b>Define</b>
<ul>The received devices created automatically.<br>
The ID of the defive are the first two Hex values of the package as dezimal.<br>
</ul>
<br>
<a name="CUL_TCM97001 Events"></a>
<a name="SIGNALduino_ID7 Events"></a>
<b>Generated events:</b>
<ul>
<li>temperature: The temperature</li>
Expand All @@ -205,15 +223,15 @@ SIGNALduino_ID7_Parse($$)
</li>
<li><a href="#do_not_notify">do_not_notify</a></li>
<li><a href="#ignore">ignore</a></li>
<li><a href="#model">model</a> (TCM97..., ABS700, TCM21...., Prologue, Rubicson, NC_WS, GT-WT-02, AURIOL, Unknown)</li>
<li><a href="#model">model</a> ()</li>
<li><a href="#showtime">showtime</a></li>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul>
<a name="CUL_TCM97001_Set"></a>
<a name="SIGNALduino_ID7_Set"></a>
<b>Set</b> <ul>N/A</ul><br>
<a name="CUL_TCM97001_Parse"></a>
<a name="SIGNALduino_ID7_Parse"></a>
<b>Set</b> <ul>N/A</ul><br>
</ul>
Expand All @@ -222,33 +240,26 @@ SIGNALduino_ID7_Parse($$)
=begin html_DE
<a name="CUL_TCM97001"></a>
<h3>CUL_TCM97001</h3>
<a name="SIGNALduino_ID7"></a>
<h3>SIGNALduino_ID7</h3>
<ul>
Das CUL_TCM97001 Module verarbeitet von einem IO Gerät (CUL, CUN, SIGNALDuino, etc.) empfangene Nachrichten von Temperatur-Sensoren.<br>
Das SIGNALduino_ID7 Module verarbeitet von einem IO Gerät (CUL, CUN, SIGNALDuino, etc.) empfangene Nachrichten von Temperatur-Sensoren.<br>
<br>
<b>Unterstütze Modelle:</b>
<ul>
<li>TCM97...</li>
<li>ABS700</li>
<li>TCM21....</li>
<li>Prologue</li>
<li>Rubicson</li>
<li>NC_WS</li>
<li>GT-WT-02</li>
<li>AURIOL</li>
<li>EAS800z</li>
</ul>
<br>
Neu empfangene Sensoren werden in der fhem Kategory CUL_TCM97001 per autocreate angelegt.
Neu empfangene Sensoren werden in der fhem per autocreate angelegt.
<br><br>
<a name="CUL_TCM97001_Define"></a>
<a name="SIGNALduino_ID7_Define"></a>
<b>Define</b>
<ul>Die empfangenen Sensoren werden automatisch angelegt.<br>
Die ID der angelgten Sensoren sind die ersten zwei HEX Werte des empfangenen Paketes in dezimaler Schreibweise.<br>
</ul>
<br>
<a name="CUL_TCM97001 Events"></a>
<a name="SIGNALduino_ID7 Events"></a>
<b>Generierte Events:</b>
<ul>
<li>temperature: Die aktuelle Temperatur</li>
Expand All @@ -266,15 +277,15 @@ SIGNALduino_ID7_Parse($$)
</li>
<li><a href="#do_not_notify">do_not_notify</a></li>
<li><a href="#ignore">ignore</a></li>
<li><a href="#model">model</a> (TCM97..., ABS700, TCM21...., Prologue, Rubicson, NC_WS, GT-WT-02, AURIOL, Unknown)</li>
<li><a href="#model">model</a> ()</li>
<li><a href="#showtime">showtime</a></li>
<li><a href="#readingFnAttributes">readingFnAttributes</a></li>
</ul>
<a name="CUL_TCM97001_Set"></a>
<a name="SIGNALduino_ID71_Set"></a>
<b>Set</b> <ul>N/A</ul><br>
<a name="CUL_TCM97001_Parse"></a>
<a name="SIGNALduino_ID7_Parse"></a>
<b>Set</b> <ul>N/A</ul><br>
</ul>
Expand Down
17 changes: 10 additions & 7 deletions controls_signalduino.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
DEL FHEM/firmware/SIGNALduino_nano328.hex
DEL FHEM/firmware/SIGNALduino_promini328.hex
DEL FHEM/firmware/SIGNALduino_uno.hex
UPD 2015_05_09_14:40:14 11496 FHEM/14_SIGNALduino_AS.pm
UPD 2015_05_09_14:40:14 7779 FHEM/14_SIGNALduino_RSL.pm
UPD 2015_15_09_22:08:41 53412 FHEM/firmware/SIGNALduino_nano328.hex
UPD 2015_15_09_22:10:56 53412 FHEM/firmware/SIGNALduino_uno.hex
UPD 2015_15_09_22:26:23 53412 FHEM/firmware/SIGNALduino_promini328.hex
UPD 2015_15_09_22:33:38 72402 FHEM/00_SIGNALduino.pm
UPD 2015_15_09_22:43:07 11530 FHEM/14_SIGNALduino_un.pm
UPD 2015_05_09_14:08:03 21 FHEM/.gitignore
UPD 2015_13_04_21:21:16 7779 FHEM/14_SIGNALduino_RSL.pm
UPD 2015_15_07_21:28:03 605 FHEM/upd.bat
UPD 2015_16_09_21:50:22 11530 FHEM/14_SIGNALduino_un.pm
UPD 2015_16_09_21:50:22 53412 FHEM/firmware/SIGNALduino_nano328.hex
UPD 2015_16_09_21:50:22 53412 FHEM/firmware/SIGNALduino_promini328.hex
UPD 2015_16_09_21:50:22 53412 FHEM/firmware/SIGNALduino_uno.hex
UPD 2015_16_09_22:15:59 72496 FHEM/00_SIGNALduino.pm
UPD 2015_16_09_22:16:03 8936 FHEM/14_SIGNALduino_ID7.pm
UPD 2015_31_08_22:41:40 11496 FHEM/14_SIGNALduino_AS.pm

0 comments on commit c9e79bf

Please sign in to comment.