diff --git a/fhem/FHEM/lib/AttrTemplate/mqtt2.template b/fhem/FHEM/lib/AttrTemplate/mqtt2.template index fde1660b3..e2799975b 100644 --- a/fhem/FHEM/lib/AttrTemplate/mqtt2.template +++ b/fhem/FHEM/lib/AttrTemplate/mqtt2.template @@ -3420,7 +3420,7 @@ set DEVICE getKnown attr DEVICE comment NOTE: additional templates and code have been downloaded from svn (contrib).
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.
NOTE: additional templates and code have been downloaded from svn (contrib).
To configure further parts of your ebus ecosystem, have a look at these templates and the Wiki, to see more info about the provided code, issue help attrTmqtt2_ebus_Utils. attr DEVICE model eBus_daemon_splitter -setreading DEVICE attrTemplateVersion 20210720 +setreading DEVICE attrTemplateVersion 20210715 name:ebus_update_files_from_svn filter:TYPE=MQTT2_DEVICE diff --git a/fhem/contrib/AttrTemplate/99_attrTmqtt2_ebus_Utils.pm b/fhem/contrib/AttrTemplate/99_attrTmqtt2_ebus_Utils.pm index 8c244e4fe..ce8d518dd 100644 --- a/fhem/contrib/AttrTemplate/99_attrTmqtt2_ebus_Utils.pm +++ b/fhem/contrib/AttrTemplate/99_attrTmqtt2_ebus_Utils.pm @@ -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__ FHEM::aTm2u_ebus::j2nv($,$$$)
This is just a wrapper to fhem.pl json2nameValue() to prevent the "_value" postfix. It will first clean the first argument by applying $EVENT=~ s,[{]"value":\s("?[^"}]+"?)[}],$1,g. +
  • FHEM::aTm2u_ebus::j2singleReading
    + FHEM::aTm2u_ebus::j2singleReading($$,$$$)
    + 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. +
  • FHEM::aTm2u_ebus::upd_day_profile
    FHEM::aTm2u_ebus::upd_day_profile($$$,$)
    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 daylist as 4th argument. daylist 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.
  • +
  • FHEM::aTm2u_ebus::analyzeReadingList
    + FHEM::aTm2u_ebus::($)
    + 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. +
  • FHEM::aTm2u_ebus::send_weekprofile
    FHEM::aTm2u_ebus::send_weekprofile($$$,$$)
    Helper function that may be capable to translate a (temperature) weekly profile provided by a weekprofile TYPE device to the ebus format (max. three pairs of on/off switching times). diff --git a/fhem/contrib/AttrTemplate/mqtt2.ebus.template b/fhem/contrib/AttrTemplate/mqtt2.ebus.template index 0491441db..8bf7a13e8 100644 --- a/fhem/contrib/AttrTemplate/mqtt2.ebus.template +++ b/fhem/contrib/AttrTemplate/mqtt2.ebus.template @@ -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.
    For details on these funtions, see commandref or help attrTmqtt2_ebus_Utils. order:E_01a02 { FHEM::aTm2u_ebus::analyzeReadingList("DEVICE") } - +farewell:Please check results now (additional devices may have been created!
    For details on the ebus specific funtions, issue help attrTmqtt2_ebus_Utils. name:eBus_bai_jsonMap_Status01 filter:TYPE=MQTT2_DEVICE