diff --git a/fhem/FHEM/lib/AttrTemplate/mqtt2.template b/fhem/FHEM/lib/AttrTemplate/mqtt2.template index a443fa792..ad90e0844 100644 --- a/fhem/FHEM/lib/AttrTemplate/mqtt2.template +++ b/fhem/FHEM/lib/AttrTemplate/mqtt2.template @@ -789,7 +789,7 @@ filter:TYPE=MQTT2_DEVICE:FILTER=CID~zigbee.* order:L_17 par:BASE_TOPIC;base topic set in configuration.yaml of the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[\b]?([^/:]+)[/].+, ? $1 : undef } par:DEV_ID;name of the device in the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[^/]+[/]([^/:]+).*, ? $1 : undef } -par:ICON;ICON as set, defaults to hm-cc-rt-dn;{ AttrVal("DEVICE","icon","hm-cc-rt-dn") } +par:ICON;ICON as set, defaults to temp_control;{ AttrVal("DEVICE","icon","temp_control") } attr DEVICE icon ICON attr DEVICE devicetopic BASE_TOPIC/DEV_ID attr DEVICE readingList $\DEVICETOPIC:.* { json2nameValue($EVENT,'',$JSONMAP) } @@ -810,7 +810,7 @@ attr DEVICE setStateList on off attr DEVICE model zigbee2mqtt_eurotronic_spirit set DEVICE attrTemplate speechcontrol_type_thermostat deletereading -q DEVICE (?!associatedWith).* -setreading DEVICE attrTemplateVersion 20201209 +setreading DEVICE attrTemplateVersion 20201218 name:zigbee2mqtt_thermostat_with_weekrofile desc: stub of a version for Model HY368-ZB manufactured by Moes via zigbee2mqtt
Not yet tested...
To contribute, participate in Forum Thread @@ -818,7 +818,7 @@ filter:TYPE=MQTT2_DEVICE:FILTER=CID~zigbee.* order:L_17a par:BASE_TOPIC;base topic set in configuration.yaml of the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[\b]?([^/:]+)[/].+, ? $1 : undef } par:DEV_ID;name of the device in the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[^/]+[/]([^/:]+).*, ? $1 : undef } -par:ICON;ICON as set, defaults to hm-cc-rt-dn;{ AttrVal("DEVICE","icon","hm-cc-rt-dn") } +par:ICON;ICON as set, defaults to temp_control;{ AttrVal("DEVICE","icon","temp_control") } par:WPNAME;weekprofile attr value, defaults to device name;{ AttrVal("DEVICE","weekprofile","DEVICE") } farewell:template has been applied successfully.
NOTE: code has been downloaded from svn (contrib).
For use with weekprofile, additional configuration is needed! { Svn_GetFile("contrib/AttrTemplate/99_attrT_z2m_thermostat_Utils.pm", "FHEM/99_attrT_z2m_thermostat_Utils.pm", sub(){ CommandReload(undef, "99_attrT_z2m_thermostat_Utils.pm") }) } @@ -833,6 +833,9 @@ attr DEVICE setList \ btnLock:LOCK,UNLOCK $\DEVICETOPIC/set {"child_lock": "$EVTPART1"}\ boost:noArg $\DEVICETOPIC/set {"preset": "boost"}\ mode:schedule,manual,boost,complex,comfort,eco $\DEVICETOPIC/set {"preset": "$EVTPART1"}\ + holidays $\DEVICETOPIC/set/schedule { "holidays":[$EVTPART1] }\ + workdays $\DEVICETOPIC/set/schedule { "workdays":[$EVTPART1] }\ + week:5+2,6+1,7 $\DEVICETOPIC/set $EVTPART1\ weekprofile { FHEM::attrT_z2m_thermostat_Utils::z2t_send_weekprofile($NAME, $EVTPART1, $EVTPART2) }\ x_send_set_payload:textField { my $payload = $EVENT;$payload =~ s/$EVTPART0 //; qq($\DEVICETOPIC/set $payload)} attr DEVICE getList desired-temp:noArg desired-temp $\DEVICETOPIC/get {"current_heating_setpoint": ""}\ @@ -849,7 +852,7 @@ attr DEVICE setStateList on off attr DEVICE model zigbee2mqtt_thermostat_with_weekrofile set DEVICE attrTemplate speechcontrol_type_thermostat deletereading -q DEVICE (?!associatedWith).* -setreading DEVICE attrTemplateVersion 20201215 +setreading DEVICE attrTemplateVersion 20201218 ########################################### diff --git a/fhem/contrib/AttrTemplate/99_attrT_z2m_thermostat_Utils.pm b/fhem/contrib/AttrTemplate/99_attrT_z2m_thermostat_Utils.pm index 87c04678d..e617662e2 100644 --- a/fhem/contrib/AttrTemplate/99_attrT_z2m_thermostat_Utils.pm +++ b/fhem/contrib/AttrTemplate/99_attrT_z2m_thermostat_Utils.pm @@ -1,5 +1,5 @@ ############################################## -# $Id: attrT_z2m_thermostat_Utils.pm 2020-12-10 Beta-User $ +# $Id$ # package FHEM::attrT_z2m_thermostat_Utils; ## no critic 'Package declaration' @@ -21,6 +21,7 @@ BEGIN { AttrVal InternalVal CommandGet + CommandSet readingsSingleUpdate readingsBulkUpdate readingsBeginUpdate @@ -28,7 +29,7 @@ BEGIN { ReadingsVal ReadingsNum ReadingsAge - decode_json + decode_json json2nameValue defs ) @@ -58,8 +59,8 @@ sub z2t_send_weekprofile { my $name = shift; my $wp_name = shift; my $wp_profile = shift // return; - my $topic = shift // AttrVal($name,'devicetopic','') . '/set'; my $model = shift // ReadingsVal($name,'week','5+2'); + my $topic = shift // AttrVal($name,'devicetopic','') . '/set'; my $hash = $defs{$name}; $topic .= ' '; @@ -70,21 +71,21 @@ sub z2t_send_weekprofile { return; } - my @D = ("Sat","Sun","Mon","Tue","Wed","Thu","Fri"); + my @D = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); my $payload; my @days = (0..6); my $text = decode_json($wp_profile_data); if ( $model eq '5+2' || $model eq '6+1') { - @days = (1,2); - $payload = '{"holidays":['; + @days = (0,1); + #$payload = '{"holidays":['; } elsif ($model eq '7') { - @days = (2); - $payload = '{"workdays":['; + @days = (1); + #$payload = '{"workdays":['; } for my $i (@days) { - $payload.='{'; + $payload = '{'; for my $j (0..7) { if (defined $text->{$D[$i]}{'time'}[$j]) { @@ -96,14 +97,17 @@ sub z2t_send_weekprofile { } } $payload .='}'; - if ($model eq '5+2' || $model eq '6+1') { - $payload .='},'if $i == 0 || $i > 1 && $i != $days[-1]; - $payload .='],"workdays":[' if $i == 1; + if ( $i == 0 && ( $model eq '5+2' || $model eq '6+1') ) { + #$payload .='},'if $i == 0 || $i > 1 && $i != $days[-1]; + #$payload .='],"workdays":[' if $i == 1; + CommandSet($defs{$name},"$name holidays $payload"); + $payload = '{'; } + CommandSet($defs{$name},"$name workdays $payload") if $model eq '5+2' || $model eq '6+1' || $model eq '7'; } - $payload .=']}'; + #$payload .=']}'; readingsSingleUpdate( $defs{$name}, 'weekprofile', "$wp_name $wp_profile",1); - return "$topic $payload"; + return; } @@ -116,6 +120,31 @@ __END__

attrT_z2m_thermostat_Utils

- + =end html =cut