mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
mqtt2.template +others: update ebus + utils
git-svn-id: https://svn.fhem.de/fhem/trunk@24777 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4916a24f18
commit
78a18a39a8
@ -3398,7 +3398,7 @@ attr DEVICE icon ICON
|
||||
modify DEVICE DEV_ID
|
||||
attr DEVICE autocreate 1
|
||||
attr DEVICE bridgeRegexp (ebus\S[^/]*?)/(bai|\d+|cc|e7f|ehp|f\d\d|hc|hc\d+|he.|hmu|hwc|mc|mc.\d|omu|omu.\d|pms|rcc|rcc.\d|sc|sdr_p|solar|ui|uih|v\d\d|v81.\d|vd\d|vl\d|vr_\d\d|zeo)/.*:.* "$1_$2"\
|
||||
(ebus\S[^/]*?)/(global|broadcast|general|scan[^/]+)/.*:.* "$1"
|
||||
(ebus\S[^/]*?)/(global|broadcast|general|scan[^/]+|memory)/.*:.* "$1"
|
||||
attr DEVICE readingList DEV_ID/scan[^/]+/.*:.* { $TOPIC =~ m,scan.([^/]+)/,; FHEM::aTm2u_ebus::j2nv($EVENT,"scan_${1}_") }\
|
||||
DEV_ID/global/uptime:.* uptime\
|
||||
DEV_ID/global/running:.* running\
|
||||
@ -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 20210715
|
||||
setreading DEVICE attrTemplateVersion 20210720
|
||||
|
||||
name:ebus_update_files_from_svn
|
||||
filter:TYPE=MQTT2_DEVICE
|
||||
|
@ -19,6 +19,7 @@ BEGIN {
|
||||
GP_Import(
|
||||
qw(
|
||||
json2nameValue
|
||||
toJSON
|
||||
AttrVal
|
||||
InternalVal
|
||||
CommandGet
|
||||
@ -52,7 +53,9 @@ sub j2nv {
|
||||
my $pre = shift;
|
||||
my $filt = shift;
|
||||
my $not = shift;
|
||||
$EVENT=~ s{[{]"value":\s("[^"]+")[}]}{$1}g;
|
||||
|
||||
return if !length $EVENT;
|
||||
$EVENT=~ s,[{]"value":\s("?[^"}]+"?)[}],$1,g;
|
||||
return json2nameValue($EVENT, $pre, $filt, $not);
|
||||
}
|
||||
|
||||
@ -60,12 +63,11 @@ sub send_weekprofile {
|
||||
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?
|
||||
my $model = shift // ReadingsVal($name,'week','unknown'); #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 $hash = $defs{$name} // return;
|
||||
|
||||
@ -79,13 +81,50 @@ sub send_weekprofile {
|
||||
my @D = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
|
||||
|
||||
my $payload;
|
||||
my @days = (0..6);
|
||||
#my @days = (0..6);
|
||||
my $text = decode_json($wp_profile_data);
|
||||
|
||||
( $model, @days ) = split m{:}xms, $model;
|
||||
( $model, my @days ) = split m{:}xms, $model;
|
||||
(my $sec,my $min,my $hour,my $mday,my $mon,my $year,my $wday,my $yday,my $isdst) = localtime;
|
||||
|
||||
@days = ( $model eq 'Mo-Fr' || $model eq 'Mo-So' ) ? (1) : ($model eq 'Sa-So' || $model eq 'holiday' ) ? (0) : (0..6) if !@days;
|
||||
my @models;
|
||||
if ( $model eq 'unknown' ) {
|
||||
my $monday = toJSON($text->{$D[1]}{time}) . toJSON($text->{$D[1]}{temp});
|
||||
my $satday = toJSON($text->{$D[6]}{time}) . toJSON($text->{$D[6]}{temp});
|
||||
my $sunday = toJSON($text->{$D[0]}{time}) . toJSON($text->{$D[0]}{temp});
|
||||
$models[0] = $satday eq $sunday && $sunday eq $monday ? '3' : $satday eq $sunday ? 2 : 0;
|
||||
$models[1] = 1;
|
||||
for my $i (2..5) {
|
||||
my $othday = toJSON($text->{$D[$i]}{time}) . toJSON($text->{$D[$i]}{temp});
|
||||
next if $othday eq $monday;
|
||||
$models[1] = 0;
|
||||
last;
|
||||
}
|
||||
@days = $models[0] == 3 ? (1) :
|
||||
$models[1] == 1 && $models[0] == 2 ? (0,1) :
|
||||
$models[1] == 1 ? (0,1,6) :
|
||||
$models[1] == 0 && $models[0] == 2 ? (0..5) : (0..6)
|
||||
}
|
||||
|
||||
if (!@days) {
|
||||
if ( $model eq 'Mo-Fr' ) {
|
||||
@days = (1);
|
||||
$models[1] = 1;
|
||||
} elsif ( $model eq 'Mo-So' ) {
|
||||
@days = (1);
|
||||
$models[1] = 1;
|
||||
$models[0] = 3;
|
||||
} elsif ( $model eq 'holiday' ) {
|
||||
@days = (0);
|
||||
} elsif ( $model eq 'selected' ) {
|
||||
@days = (0..6);
|
||||
$models[1] = 0;
|
||||
$models[0] = 0;
|
||||
} elsif ( $model eq 'Sa-So' ) {
|
||||
@days = (0);
|
||||
$models[0] = 2;
|
||||
}
|
||||
}
|
||||
|
||||
for my $i (@days) {
|
||||
$payload = q{};
|
||||
@ -102,7 +141,6 @@ sub send_weekprofile {
|
||||
$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] ) {
|
||||
@ -116,8 +154,18 @@ sub send_weekprofile {
|
||||
if ( $model eq 'holiday' ) {
|
||||
$payload .= 'selected';
|
||||
CommandSet($defs{$name},"$name $Dl[$wday] $payload") if ReadingsVal($name,$Dl[$wday],'') ne $payload;
|
||||
} elsif ( $model eq 'selected' ) {
|
||||
$payload .= 'selected';
|
||||
CommandSet($defs{$name},"$name $Dl[$i] $payload") if ReadingsVal($name,$Dl[$i],'') ne $payload;
|
||||
} elsif ($i == 1) {
|
||||
$payload .= defined $models[0] && $models[0] == 3 ? 'Mo-So' : defined $models[1] && $models[1] ? 'Mo-Fr' : 'selected';
|
||||
CommandSet($defs{$name},"$name $Dl[$i] $payload") if ReadingsVal($name,$Dl[$i],'') ne $payload;
|
||||
} elsif ($i == 0 || $i == 6 ) {
|
||||
my $united = defined $models[0] && $models[0] == 2;
|
||||
$payload .= $united ? 'Sa-So' : 'selected';
|
||||
CommandSet($defs{$name},"$name $Dl[$united ? 6 : $i] $payload") if ReadingsVal($name,$Dl[$united ? 6 : $i],'') ne $payload;
|
||||
} else {
|
||||
$payload .= $model;
|
||||
$payload .= 'selected';
|
||||
CommandSet($defs{$name},"$name $Dl[$i] $payload") if ReadingsVal($name,$Dl[$i],'') ne $payload;
|
||||
}
|
||||
}
|
||||
@ -152,6 +200,7 @@ sub upd_day_profile {
|
||||
my $daylist = shift // q(Su|Mo|Tu|We|Th|Fr|Sa);
|
||||
|
||||
my $hash = $defs{$name} // return;
|
||||
return if !length $payload;
|
||||
|
||||
my @Dl = ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
|
||||
|
||||
@ -212,7 +261,15 @@ __END__
|
||||
<ul>
|
||||
<li><b>aTm2u_ebus::j2nv</b><br>
|
||||
<code>aTm2u_ebus::j2nv($,$$$)</code><br>
|
||||
This ist 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>.
|
||||
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>aTm2u_ebus::upd_day_profile</b><br>
|
||||
<code>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>aTm2u_ebus::send_weekprofile</b><br>
|
||||
<code>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).
|
||||
</li>
|
||||
<li><b>aTm2u_ebus::createBarView</b><br>
|
||||
<code>aTm2u_ebus::createBarView($,$$)</code><br>
|
||||
|
Loading…
x
Reference in New Issue
Block a user