2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

00_MYSENSORS: enhance support for multiple GW-nodes

10_MYSENSORS_DEVICE: 
- change internal timer usage to comply to fhem standards
- add support for attrTemplate


git-svn-id: https://svn.fhem.de/fhem/trunk@19108 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Beta-User 2019-04-04 04:08:41 +00:00
parent f1b7a331de
commit b068007bf3
5 changed files with 147 additions and 10 deletions

View File

@ -1,5 +1,8 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- feature: 10_MYSENSORS_DEVICE: add attrTemplate support
- change: 00_MYSENSORS: enhance support for node functions
when using multiple GW's
- feature: 93_DbRep: new aggregation type year - feature: 93_DbRep: new aggregation type year
- bugfix 73_AMADCommBridge: fix little bug - bugfix 73_AMADCommBridge: fix little bug
- bugfix: 70_BRAVIA: fix channel presets, fix use of ReadingsAge - bugfix: 70_BRAVIA: fix channel presets, fix use of ReadingsAge

View File

@ -56,15 +56,18 @@ sub MYSENSORS_Initialize($) {
$hash->{AttrFn} = "MYSENSORS::Attr"; $hash->{AttrFn} = "MYSENSORS::Attr";
$hash->{NotifyFn} = "MYSENSORS::Notify"; $hash->{NotifyFn} = "MYSENSORS::Notify";
$hash->{AttrList} = my @attrList = qw(
"autocreate:1 ". autocreate:1
"requestAck:1 ". requestAck:1
"first-sensorid ". first-sensorid
"last-sensorid ". last-sensorid
"stateFormat ". stateFormat
"OTA_firmwareConfig"; OTA_firmwareConfig
);
$hash->{AttrList} = $hash->{AttrList} = join(" ", @attrList)
} }
package MYSENSORS; package MYSENSORS;
use Exporter ('import'); use Exporter ('import');
@ -330,7 +333,10 @@ sub onPresentationMsg($$) {
unless ($client) { unless ($client) {
if ($hash->{'inclusion-mode'}) { if ($hash->{'inclusion-mode'}) {
$clientname = "MYSENSOR_$msg->{radioId}"; $clientname = "MYSENSOR_$msg->{radioId}";
$clientname = "$hash->{NAME}_DEVICE_0"if defined $main::defs{$clientname};
CommandDefine(undef,"$clientname MYSENSORS_DEVICE $msg->{radioId}"); CommandDefine(undef,"$clientname MYSENSORS_DEVICE $msg->{radioId}");
CommandAttr(undef,"$clientname IODev $hash->{NAME}");
CommandAttr(undef,"$clientname room MYSENSORS_DEVICE");
$client = $main::defs{$clientname}; $client = $main::defs{$clientname};
return unless ($client); return unless ($client);
} else { } else {
@ -385,8 +391,9 @@ sub onInternalMsg($$) {
last; last;
}; };
$type == I_HEARTBEAT_RESPONSE and do { $type == I_HEARTBEAT_RESPONSE and do {
RemoveInternalTimer($hash,"MYSENSORS::Start"); ## Reset reconnect because timeout was not reached RemoveInternalTimer($hash,"MYSENSORS::Start"); ## Reset reconnect because timeout was not reached
readingsSingleUpdate($hash, "heartbeat", "last", 0); readingsSingleUpdate($hash, "heartbeat", "alive", 0);
if (my $client = matchClient($hash,$msg)){ MYSENSORS::DEVICE::onInternalMessage($client,$msg) };
}; };
$type == I_VERSION and do { $type == I_VERSION and do {
$hash->{version} = $msg->{payload}; $hash->{version} = $msg->{payload};

View File

@ -55,6 +55,7 @@ sub MYSENSORS_DEVICE_Initialize($) {
OTA_autoUpdate:0,1 OTA_autoUpdate:0,1
OTA_BL_Type:Optiboot,MYSBootloader OTA_BL_Type:Optiboot,MYSBootloader
OTA_Chan76_IODev OTA_Chan76_IODev
model
); );
use warnings 'qw'; use warnings 'qw';
$hash->{AttrList} = join(" ", @attrList)." ".$readingFnAttributes; $hash->{AttrList} = join(" ", @attrList)." ".$readingFnAttributes;
@ -250,7 +251,7 @@ sub Set($@) {
$hash->{sets}->{fwType} = join(",", MYSENSORS::getFirmwareTypes($hash->{IODev})); $hash->{sets}->{fwType} = join(",", MYSENSORS::getFirmwareTypes($hash->{IODev}));
my $list = join(" ", map {$hash->{sets}->{$_} ne "" ? "$_:$hash->{sets}->{$_}" : $_} sort keys %{$hash->{sets}}); my $list = join(" ", map {$hash->{sets}->{$_} ne "" ? "$_:$hash->{sets}->{$_}" : $_} sort keys %{$hash->{sets}});
$hash->{sets}->{fwType} = ""; $hash->{sets}->{fwType} = "";
return grep (/(^on$)|(^off$)/,keys %{$hash->{sets}}) == 2 ? SetExtensions($hash, $list, $name, $command, @values) : "Unknown argument $command, choose one of $list"; return SetExtensions($hash, $list, $name, $command, @values);
} }
COMMAND_HANDLER: { COMMAND_HANDLER: {
@ -1163,24 +1164,39 @@ sub sendRetainedMessages($) {
<a name="MYSENSORS_DEVICEset"></a> <a name="MYSENSORS_DEVICEset"></a>
<p><b>Set</b></p> <p><b>Set</b></p>
<ul> <ul>
<b>AttrTemplate</b>
<li>Helps to easily configure your devices. Just get a list of all available attrTremplates by issuing
<ul>
<p><code>set &lt;name&gt; attrTemplate ?</code></p>
</ul>
Have a look at the descriptions and choose a suitable one. Then use the drop-down list and click "set" or issue a.<br>
<ul>
<p><code>set &lt;name&gt; attrTemplate A_02a_atmospheric_pressure</code></p>
</ul>
</li><br>
<b>clear</b>
<li> <li>
<p><code>set &lt;name&gt; clear</code><br/>clears MySensors EEPROM area and reboot (i.e. "factory" reset) - requires MY_SPECIAL_DEBUG</p> <p><code>set &lt;name&gt; clear</code><br/>clears MySensors EEPROM area and reboot (i.e. "factory" reset) - requires MY_SPECIAL_DEBUG</p>
</li> </li>
<b>flash</b>
<li> <li>
<p><code>set &lt;name&gt; flash</code><br/> <p><code>set &lt;name&gt; flash</code><br/>
Checks whether a newer firmware version is available. If a newer firmware version is Checks whether a newer firmware version is available. If a newer firmware version is
available the flash procedure is started. The sensor node must support FOTA for available the flash procedure is started. The sensor node must support FOTA for
this.</p> this.</p>
</li> </li>
<b>fwType</b>
<li> <li>
<p><code>set &lt;name&gt; fwType &lt;value&gt;</code><br/> <p><code>set &lt;name&gt; fwType &lt;value&gt;</code><br/>
assigns a firmware type to this node (must be a numeric value in the range 0 .. 65536). assigns a firmware type to this node (must be a numeric value in the range 0 .. 65536).
Should be contained in the <a href="#MYSENSORSattrOTA_firmwareConfig">FOTA configuration Should be contained in the <a href="#MYSENSORSattrOTA_firmwareConfig">FOTA configuration
file</a>.</p> file</a>.</p>
</li> </li>
<b>time</b>
<li> <li>
<p><code>set &lt;name&gt; time</code><br/>sets time for nodes (that support it)</p> <p><code>set &lt;name&gt; time</code><br/>sets time for nodes (that support it)</p>
</li> </li>
<b>reboot</b>
<li> <li>
<p><code>set &lt;name&gt; reboot</code><br/>reboots a node (requires a bootloader that supports it).<br/>Attention: Nodes that run the standard arduino-bootloader will enter a bootloop!<br/>Dis- and reconnect the nodes power to restart in this case.</p> <p><code>set &lt;name&gt; reboot</code><br/>reboots a node (requires a bootloader that supports it).<br/>Attention: Nodes that run the standard arduino-bootloader will enter a bootloop!<br/>Dis- and reconnect the nodes power to restart in this case.</p>
</li> </li>

View File

@ -0,0 +1,110 @@
###########################################
# $Id: $
#
# Comments start with #. Empty lines are ignored.
# Syntax of one entry: name: line, one optional filter: line, zero or more par: lines, FHEM-Commands
# filter:INTERNAL=VALUE (optional)
# par: name of the parameter; comment; perl_code (optional)
# perl_code returns a value for the parameter, or undef.
# If undef, the user has to specify them (the comment is shown to the user)
###########################################
# Example sketches from MySensors.org
# simple stateFormat versions
name:A_01a1_air_humidity_dht
filter:TYPE=MYSENSORS_DEVICE
desc:Applies to standard DHT sketch without battery reading<br>NOTE: Untested first template version
attr DEVICE stateFormat T: temperature1 H: humidity
attr DEVICE model A_01a1_air_humidity_dht
name:A_01a2_air_humidity_Si7021
filter:TYPE=MYSENSORS_DEVICE
desc:Applies to standard DHT sketch with battery reading<br>NOTE: Untested first template version
attr DEVICE stateFormat T: temperature1 H: humidity Bat: batteryLevel
attr DEVICE model A_01a2_air_humidity_Si7021
name:A_02a_atmospheric_pressure
filter:TYPE=MYSENSORS_DEVICE
desc:Applies to standard Atmospheric Pressure sketch (BME280)NOTE: Untested first template version
attr DEVICE stateFormat T: temperature H: humidity1 P: pressure2 Forecast: forecast2
attr DEVICE model A_02a_atmospheric_pressure
name:A_03a_bed_occupancy
filter:TYPE=MYSENSORS_DEVICE
desc:Applies to standard bed occupancy sketch (MPR121) <br>NOTE: Sketch is still in MySensors 1.x format and has to be changed for use with recent arduino libs.NOTE: Untested first template version
attr DEVICE stateFormat Left: motion Right: motion1
attr DEVICE model A_03a_bed_occupancy
#A_04a_Dimmer - LED
#A_05a_Display and Time
#A_06a_Distance
#A_07a_Dollhouse
#A_08a_Door/Window/Button
#A_09a_Dust
#A_10a_Gas Detection
#A_11a_Gesture Controller
#A_12a_GPS Sensor
#A_13a_Heatpump Control
#A_14a_IR Sender/Receiver
#A_15a_Irrigation Controller
#A_16a1_Light Level - BH1750
#A_16a2_Light Level - LM393
name:A_17a_Motion
filter:TYPE=MYSENSORS_DEVICE
desc:Applies to standard motion sketch
attr DEVICE stateFormat Motion: motion1
attr DEVICE model A_17a_Motion
#A_18a_Orientation Actuator
#A_19a_Orientation Sensor
#A_20a_Parking Sensor
#A_21a_Pulse Power Meter
#A_22a_Pulse Water Meter
#A_23a_Rain Gauge
#A_24a_Relay Actuator
#A_25a_RFID
#A_26a_Scene Controller
#A_27a_Secret Knock
#A_28a_Servo
#A_29a_Smart Alarm Clock
#A_30a_Soil Moisture
#A_31a_Sonoff Relay
#A_32a_Starry Sky
name:A_33a_temperature
filter:TYPE=MYSENSORS_DEVICE
desc:Applies to standard temperature sketch (DS18B20) NOTE: Untested first template version
attr DEVICE stateFormat T0: temperature T1: temperature1 T2: temperature2
attr DEVICE model A_33a_temperature
#A_34a_UV
#A_35a_Whole House Fan
###########################################
# Example sketches from MySensors.org
# Advanced stateFormat and devStateIcon versions
###########################################
# Advanced sketches
#4 relay
name:C_04_4ch_unified_icon
filter:TYPE=MYSENSORS_DEVICE
desc:Device with 4 relays attached <br>NOTE: Clicking on icons will issue a corresponding toggle command
attr DEVICE devStateIcon {\
"<div><a href=\"/fhem?cmd.dummy=set ".$name." status1 toggle&XHR=1\">status1:"\
. FW_makeImage(lc ReadingsVal($name, "status1", "off"))\
. "</a> <a href=\"/fhem?cmd.dummy=set ".$name." status2 toggle&XHR=1\">status2:"\
. FW_makeImage(lc ReadingsVal($name, "status2", "off")) . "</a></div>"\
. "</a> <a href=\"/fhem?cmd.dummy=set ".$name." status3 toggle&XHR=1\">status3:"\
. FW_makeImage(lc ReadingsVal($name, "status3", "off")) . "</a></div>"\
. "</a> <a href=\"/fhem?cmd.dummy=set ".$name." status4 toggle&XHR=1\">status4:"\
. FW_makeImage(lc ReadingsVal($name, "status4", "off")) . "</a></div>"\
}
attr DEVICE stateFormat P1: status1 P2: status2 P3: status3 P4: status4 Status: state
attr DEVICE webCmd :
attr DEVICE model C_04_4ch_unified_icon

View File

@ -565,6 +565,7 @@ FHEM/lib/*deviceconfig.xml.gz krikan ZWave
FHEM/lib/*manufacturer_specific.xml krikan ZWave FHEM/lib/*manufacturer_specific.xml krikan ZWave
FHEM/lib/AttrTemplate/httpmod.template Beta-User https://forum.fhem.de/index.php/topic,97694.0.html FHEM/lib/AttrTemplate/httpmod.template Beta-User https://forum.fhem.de/index.php/topic,97694.0.html
FHEM/lib/AttrTemplate/mqtt2.template Beta-User https://forum.fhem.de/index.php/topic,94494.0.html FHEM/lib/AttrTemplate/mqtt2.template Beta-User https://forum.fhem.de/index.php/topic,94494.0.html
FHEM/lib/AttrTemplate/mysensors.template Beta-User Bastelecke/MySensors
FHEM/lib/Device/Firmata/* jensb Sonstige Systeme FHEM/lib/Device/Firmata/* jensb Sonstige Systeme
FHEM/lib/Device/MySensors/* Hauswart/Beta-User Bastelecke/MySensors FHEM/lib/Device/MySensors/* Hauswart/Beta-User Bastelecke/MySensors
FHEM/lib/MP3/* Reinerlein Multimedia FHEM/lib/MP3/* Reinerlein Multimedia