2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

mqtt2.template +others: cref to id; update ebus utils

git-svn-id: https://svn.fhem.de/fhem/trunk@24767 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Beta-User 2021-07-18 06:20:20 +00:00
parent 9b0446c619
commit bf8cc6da4b
4 changed files with 64 additions and 15 deletions

View File

@ -3387,7 +3387,7 @@ setreading DEVICE attrTemplateVersion 20200602
#ebus daemon device
name:eBus_daemon_splitter
filter:TYPE=MQTT2_DEVICE
desc:Device containing all status messages from the ebus daemon itself<br>NOTE: acts also as a bridge device to split up the hardware on the bus into different mqtt2_devices<br>NOTE:<br>- for use with MQTT2_CLIENT use a copy of the Device with the same clientId than the IO, delete original's readingList after applying the template!<br>- this might change the devices CID
desc:Device containing all status messages from the ebus daemon itself<br>NOTE: acts also as a bridge device to split up the hardware on the bus into different mqtt2_devices<br>NOTE:<br>- for use with MQTT2_CLIENT use a copy of the Device with the same clientId than the IO, delete original's readingList after applying the template!<br>- this might change the devices CID<br>-To configure further parts of your ebus ecosystem, additional templates will be available, for details see <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>.
order:E_01a
par:DEVTYPE;Internal TYPE of the device; { InternalVal("DEVICE",'TYPE',undef)}
par:DEV_ID;base topic set ebus;{ AttrVal("DEVICE",'readingList','') =~ m,[^:]+:?(ebus[a-zA-Z][^/]*)[/].*:, ? $1 : 'ebusd' }
@ -3418,10 +3418,17 @@ attr DEVICE setList getKnown:noArg DEV_ID/list onlyknown\
getAll:noArg DEV_ID/list
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>.
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 20210715
name:ebus_update_files_from_svn
filter:TYPE=MQTT2_DEVICE
desc:template to download or update additional code and attrTemplates from svn. Might be usefull in case there had been some updates...
order:E_01a1
{ Svn_GetFile('contrib/AttrTemplate/99_attrTmqtt2_ebus_Utils.pm', 'FHEM/99_attrTmqtt2_ebus_Utils.pm', sub(){ CommandReload(undef, '99_attrTmqtt2_ebus_Utils') }) }
{ Svn_GetFile("contrib/AttrTemplate/mqtt2.ebus.template", "FHEM/lib/AttrTemplate/mqtt2.ebus.template", sub(){ AttrTemplate_Initialize() }) }
farewell:Download has been initiated. You may find <a href=https://wiki.fhem.de/wiki/EBUS-MQTT2">Wiki</a> usefull; to see more info about the provided code, issue <i>help attrTmqtt2_ebus_Utils</i>
###########################################
# ems-esp

View File

@ -119,7 +119,7 @@ __END__
=pod
=begin html
<a name="attrT_z2m_thermostat_Utils"></a>
<a id="attrT_z2m_thermostat_Utils"></a>
<h3>attrT_z2m_thermostat_Utils</h3>
<ul>
<b>z2t_send_weekprofile</b>

View File

@ -57,15 +57,17 @@ sub j2nv {
}
sub send_weekprofile {
my $name = shift;
my $wp_name = shift;
my $name = shift // return;
my $wp_name = shift // return;
my $wp_profile = shift // return;
my $model = shift // ReadingsVal($name,'week','selected'); #selected,Mo-Fr,Mo-So,Sa-So? holiday to set actual $wday to sunday program?
#[quote author=Reinhart link=topic=97989.msg925644#msg925644 date=1554057312]
#"daysel" nicht. Für mich bedeutet dies, das das Csv mit der Feldbeschreibung nicht überein stimmt. Ich kann aber nirgends einen Fehler sichten (timerhc.inc oder _templates.csv). [code]daysel,UCH,0=selected;1=Mo-Fr;2=Sa-So;3=Mo-So,,Tage[/code]
#Ebenfalls getestet mit numerischem daysel (0,1,2,3), auch ohne Erfolg.
my $onLimit = shift // '20';
my $topic = shift // AttrVal($name,'devicetopic','') . '/hcTimer.$wkdy/set ';
my $onLimit = shift // '20';
my $hash = $defs{$name};
my $hash = $defs{$name} // return;
my $wp_profile_data = CommandGet(undef,"$wp_name profile_data $wp_profile 0");
if ($wp_profile_data =~ m{(profile.*not.found|usage..profile_data..name)}xms ) {
@ -97,26 +99,26 @@ sub send_weekprofile {
my $val = $text->{$D[$i]}{temp}[$j];
if ( $val eq $onOff || (looks_like_number($val) && _compareOnOff( $val, $onOff, $onLimit ) ) ) {
$time = '00:00' if !$j;
$payload .= qq{$time;;$text->{$D[$i]}{time}[$j];;};
$payload .= qq{$time;$text->{$D[$i]}{time}[$j];};
$pairs++;
$val = $val eq 'on' ? 'off' : 'on';
#$time = $text->{$D[$i]}{time}[$j] if $j;
}
}
while ( $pairs < 3 && !defined $text->{$D[$i]}{time}[$j] ) {
#fill up the three pairs with last time
$time = $text->{$D[$i]}{time}[$j-1];
$pairs++;
$payload .= qq{-:-;;-:-;;};
$payload .= qq{-,-;-,-;};
}
last if $pairs == 3;
}
if ( $model eq 'holiday' ) {
$payload .= 'selected';
CommandSet($defs{$name},"$name $Dl[$wday] $payload")
CommandSet($defs{$name},"$name $Dl[$wday] $payload") if ReadingsVal($name,$Dl[$wday],'') ne $payload;
} else {
$payload .= $model;
CommandSet($defs{$name},"$name $Dl[$i] $payload");
CommandSet($defs{$name},"$name $Dl[$i] $payload") if ReadingsVal($name,$Dl[$i],'') ne $payload;
}
}
@ -137,6 +139,46 @@ sub _compareOnOff {
return;
}
#ebusd/hc1/HP1.Mo.1:.* { json2nameValue($EVENT) }
#zwei Readings "Start_value" und "End_value"
# Vermutung: { "Start": {"value": "10:00"}, "End": {"value": "11:00"}}
#ebusd/hc1/HP1\x2eMo\x2e2:.* { json2nameValue($EVENT) }
sub upd_day_profile {
my $name = shift // return;
my $topic = shift // return;
my $payload = shift // return;
my $daylist = shift // q(Su|Mo|Tu|We|Th|Fr|Sa);
my $hash = $defs{$name} // return;
my @Dl = ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
my $data = decode_json($payload);
$topic =~ m{[.](?<dayshort>$daylist)[.](?<pair>[1-3])\z}xms;
my $shday = $+{dayshort} // return;
my $pairNr = $+{pair} // return;
$pairNr--;
my @days = split m{\|}xms, $daylist;
my %days_index = map { $days[$_] => $_ } (0..6);
my $index = $days_index{$shday};
#Log3(undef,3, "[$name] day $shday, pair $pairNr, index $index days @days");
return if !defined $index;
my $rVal = ReadingsVal( $name, $Dl[$index], '-,-;-,-;-,-;-,-;-,-;-,-;Mo-So' );
my @times = split m{;}xms, $rVal;
$times[$pairNr*2] = $data->{Start}->{value};
$times[$pairNr*2+1] = $data->{End}->{value};
$rVal = join q{;}, @times;
readingsSingleUpdate( $defs{$name}, $Dl[$index], $rVal, 1);
return;
}
sub createBarView {
my ($val,$maxValue,$color) = @_;
$maxValue = $maxValue//100;
@ -162,7 +204,7 @@ __END__
=pod
=begin html
<a name="attrTmqtt2_ebus_Utils"></a>
<a id="attrTmqtt2_ebus_Utils"></a>
<h3>attrTmqtt2_ebus_Utils</h3>
<ul>
<b>Functions to support attrTemplates for ebusd</b><br>

View File

@ -59,7 +59,7 @@ EOD
=pod
=begin html
<a name="attrTmqtt2_roborock_Utils"></a>
<a id="attrTmqtt2_roborock_Utils"></a>
<h3>attrTmqtt2_roborock_Utils</h3>
<ul>
<b>Functions to support attrTemplates for roborock/valetudo</b><br>