2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-12 02:39:57 +00:00

mqtt2.template: OpenMQTTGateway + ebus updates (+ utils)

git-svn-id: https://svn.fhem.de/fhem/trunk@24789 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Beta-User 2021-07-23 05:21:24 +00:00
parent 7ac0368af9
commit d5a2cc3dc3
3 changed files with 32 additions and 5 deletions

View File

@ -3420,7 +3420,7 @@ set DEVICE getKnown
attr DEVICE comment NOTE: additional templates and code have been downloaded from svn (contrib).<br>Pls. inform the maintainer, if the bridgeRegexp doesn't fit to all of your devices connected to the bus.
farewell:template has been applied successfully. <br>NOTE: additional templates and code have been downloaded from svn (contrib). <br>To configure further parts of your ebus ecosystem, have a look at these templates and the <a href=https://wiki.fhem.de/wiki/EBUS-MQTT2">Wiki</a>, to see more info about the provided code, issue <i>help attrTmqtt2_ebus_Utils</i>.
attr DEVICE model eBus_daemon_splitter
setreading DEVICE attrTemplateVersion 20210720
setreading DEVICE attrTemplateVersion 20210715
name:ebus_update_files_from_svn
filter:TYPE=MQTT2_DEVICE

View File

@ -28,7 +28,7 @@ BEGIN {
CommandAttr
CommandDefine
CommandDeleteReading
CommandVersion
FileRead
FmtDateTime
readingsSingleUpdate
readingsBulkUpdate
@ -40,6 +40,7 @@ BEGIN {
json2nameValue
addToDevAttrList
defs
attr
Log3
trim
)
@ -221,7 +222,7 @@ sub analyzeReadingList {
my $cid = $defs{$name}{CID};
my $dt = $defs{$name}{DEVICETOPIC};
my $revsn = (split q{\n}, CommandVersion(undef, 'attrTmqtt2_ebus_Utils noheader'))[0] // 'unknown';
my $revsn = _getVersion();
$revsn = FmtDateTime(time) . " $revsn";
my $attrTemplt = q{ebus_analyzeReadingList};
@ -363,6 +364,7 @@ sub analyzeReadingList {
$func = q<{ FHEM::aTm2u_ebus::j2singleReading( > . qq{'$short', }. q<$EVENT, '', $JSONMAP ) }>;
$newline = qq{$newtop $func};
$rList_new .= $rList_new ? qq{\n$newline} : qq{$newline};
CommandDeleteReading(undef, "$name ${short}_.*");
next;
}
@ -446,6 +448,23 @@ sub createBarView {
return $stylestring;
}
sub _getVersion {
my $modpath = (exists($attr{global}{modpath}) ? $attr{global}{modpath} : "");
my $fn = "$modpath.FHEM/99_attrTmqtt2_ebus_Utils.pm"; # configDB
my ($ret, @content) = FileRead($fn);
if ($ret) {
Log3(undef, 1, "Error reading file $fn!") ;
return 'unknown';
}
for (@content) {
chomp;
if(m{#.*\$Id\:[^\$\n\r].+\$}xm) {
return $_;
}
}
return 'unknown';
}
1;
__END__
@ -462,10 +481,18 @@ __END__
<code>FHEM::aTm2u_ebus::j2nv($,$$$)</code><br>
This is just a wrapper to fhem.pl json2nameValue() to prevent the "_value" postfix. It will first clean the first argument by applying <code>$EVENT=~ s,[{]"value":\s("?[^"}]+"?)[}],$1,g</code>.
</li>
<li><b>FHEM::aTm2u_ebus::j2singleReading</b><br>
<code>FHEM::aTm2u_ebus::j2singleReading($$,$$$)</code><br>
This is another wrapper to fhem.pl json2nameValue(), that will write all key/value pairs to a single reading. the name of the reading has to be handed over as first argument, the others (starting with JSON string ($EVENT) are identical to json2nameValue/j2nv.
</li>
<li><b>FHEM::aTm2u_ebus::upd_day_profile</b><br>
<code>FHEM::aTm2u_ebus::upd_day_profile($$$,$)</code><br>
Helper function to collect weekprofile info received over different topics. $NAME, $TOPIC and $EVENT are obligatory to be handed over, additionally you may provide a <i>daylist</i> as 4th argument. <i>daylist</i> defaults to Su|Mo|Tu|We|Th|Fr|Sa. Generated readings will be named Sunday, Monday, ..., so make sure to use different MQTT2-devices for each topic-group, if there's more than one item attached to your ebus capable to use weekly profiles.
</li>
<li><b>FHEM::aTm2u_ebus::analyzeReadingList</b><br>
<code>FHEM::aTm2u_ebus::($)</code><br>
This is a helper function. It analyzes a reading list of a given FHEM device (and the existing reading names) and tries to assign one of the above mentionned special functions to each line instead of json2nameValue(). Lines without Perl statements or already using these functions are ignored. This works best, if autocreate in "complex" mode had been used to automatically build the readingList.
</li>
<li><b>FHEM::aTm2u_ebus::send_weekprofile</b><br>
<code>FHEM::aTm2u_ebus::send_weekprofile($$$,$$)</code><br>
Helper function that may be capable to translate a (temperature) <i>weekly profile<i> provided by a <i>weekprofile<i> TYPE device to the ebus format (max. three pairs of on/off switching times).

View File

@ -18,10 +18,10 @@
name:eBus_analyzeReadingList
filter:TYPE=MQTT2_DEVICE
desc:The JSON messages generated by ebusd are special. The code provided by 99_attrTmqtt2_ebus_Utils.pm includes some special functions to get shorter reading names (e.g. without the _value appendix). This template calls a function to analyze the readingList attribute and the available readings to find out which kind of pree-treatment seems to be appropriate for each line calling json2nameValue(). This works best if autocreate in "complex" mode had been used to fill the readingList attribute.
desc:The JSON messages generated by ebusd are special. The code provided by 99_attrTmqtt2_ebus_Utils.pm includes some special functions to get shorter reading names (e.g. without the _value appendix). This template calls a function to analyze the readingList attribute and the available readings to find out which kind of pree-treatment seems to be appropriate for each line calling json2nameValue(). This works best if autocreate in "complex" mode had been used to fill the readingList attribute. <br>For details on these funtions, see commandref or <code>help attrTmqtt2_ebus_Utils</code>.
order:E_01a02
{ FHEM::aTm2u_ebus::analyzeReadingList("DEVICE") }
farewell:Please check results now (additional devices may have been created!<br>For details on the ebus specific funtions, issue <code>help attrTmqtt2_ebus_Utils</code>.
name:eBus_bai_jsonMap_Status01
filter:TYPE=MQTT2_DEVICE