diff --git a/fhem/CHANGED b/fhem/CHANGED index 882c733c8..68af29db1 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it + - feature: 98_weekprofile: attribute extraClientModules + to support further modules with attribute weekprofile - feature: 76_SolarForecast: graphicControl keys beamPaddingBottom/Top - fix/new: 36_Shelly: log fw-check, model of Shelly3EM, PLUGS_UI implemented - fix/new: 36_Shelly: log fw-check, model of Shelly3EM, PLUGS_UI implemented diff --git a/fhem/FHEM/98_weekprofile.pm b/fhem/FHEM/98_weekprofile.pm index e1bd56f34..db9d668f6 100644 --- a/fhem/FHEM/98_weekprofile.pm +++ b/fhem/FHEM/98_weekprofile.pm @@ -184,7 +184,7 @@ sub weekprofile_getDeviceType($$;$) return undef if (!defined($model)); } Log3($me, 5, "$me(getDeviceType): $devHash->{NAME}, $model"); - $type = "HMCCU_IP" if ( $model =~ m/HmIP.*/ ); + $type = "HMCCU_IP" if ( $model =~ m/HmIP.*/ ); $type = "HMCCU_HM" if ( $model =~ m/HM-.*/ ); } @@ -213,6 +213,19 @@ sub weekprofile_getDeviceType($$;$) else { Log3($me, 4, "$me(getDeviceType): found MQTT2_DEVICE but not configured for weekprofile"); } + } elsif (defined AttrVal($me,'extraClientModules',undef)) { + for my $attribute_type (split m{\s+}x, AttrVal($me,'extraClientModules','')) { + if ($devType eq $attribute_type) { + my $attr = AttrVal($device,'weekprofile',''); + Log3($me, 5, "$me(getDeviceType): attr $devType $attr"); + if ($attr ne "") { + $type = 'extraClient'; + } else { + Log3($me, 4, "$me(getDeviceType): found $devType but not configured for weekprofile"); + } + } + last if $type; + } } if (defined($type)) { @@ -399,14 +412,14 @@ sub weekprofile_sendDevProfile(@) return fhem("set $device profile_data $prf->{TOPIC}:$prf->{NAME} $json_text",1); } - elsif ($type eq "WDT") { + elsif ($type eq 'WDT' || $type eq 'MQTT2_DEVICE') { my $cmd = "set $device weekprofile $me:$prf->{TOPIC}:$prf->{NAME}"; - Log3($me, 4, "$me(sendDevProfile): send to WDT $cmd"); + Log3($me, 4, "$me(sendDevProfile): send to $type $cmd"); return fhem("$cmd",1); } - elsif ($type eq "MQTT2_DEVICE") { + elsif ($type eq 'extraClient') { my $cmd = "set $device weekprofile $me $prf->{TOPIC}:$prf->{NAME}"; - Log3($me, 4, "$me(sendDevProfile): send to MQTT2_DEVICE $cmd"); + Log3($me, 4, "$me(sendDevProfile): send to extraClient device $device $cmd"); return fhem("$cmd",1); } @@ -576,7 +589,11 @@ sub weekprofile_refreshSendDevList($) my $module = $defs{$d}{TYPE}; my %sndHash; - @sndHash{@DEVLIST_SEND}=(); + my @DEVLIST_SEND_Extra = @DEVLIST_SEND; + if (defined AttrVal($me,'extraClientModules',undef)) { + push @DEVLIST_SEND_Extra, split m{\s+}x, AttrVal($me,'extraClientModules',''); + } + @sndHash{@DEVLIST_SEND_Extra}=(); next if (!exists $sndHash{$module}); my $type = weekprofile_getDeviceType($me, $defs{$d}{NAME},"SND"); @@ -614,7 +631,11 @@ sub weekprofile_receiveList($) my $module = $defs{$d}{TYPE}; my %sndHash; - @sndHash{@DEVLIST_SEND}=(); + my @DEVLIST_SEND_Extra = @DEVLIST_SEND; + if (defined AttrVal($me,'extraClientModules',undef)) { + push @DEVLIST_SEND_Extra, split m{\s+}x, AttrVal($me,'extraClientModules',''); + } + @sndHash{@DEVLIST_SEND_Extra}=(); next if (!exists $sndHash{$module}); my $type = weekprofile_getDeviceType($me, $defs{$d}{NAME}); @@ -727,7 +748,7 @@ sub weekprofile_Initialize($) $hash->{NotifyFn} = "weekprofile_Notify"; $hash->{AttrFn} = "weekprofile_Attr"; $hash->{AttrList} = "useTopics:0,1 widgetTranslations widgetWeekdays widgetTempRange widgetEditOnNewPage:0,1 widgetEditDaysInRow:1,2,3,4,5,6,7 \ - sendDelay tempON tempOFF configFile forceCompleteProfile:0,1 tempMap sendKeywordsToDevices:0,1 ".$readingFnAttributes; + sendDelay tempON tempOFF configFile forceCompleteProfile:0,1 tempMap sendKeywordsToDevices:0,1 extraClientModules ".$readingFnAttributes; $hash->{FW_summaryFn} = "weekprofile_SummaryFn"; @@ -1403,6 +1424,10 @@ sub weekprofile_Attr($$$) if ($attrName eq 'tempMap') { weekprofile_createTempMap($hash, $attrVal); } + + if ($attrName eq 'extraClientModules') { + + } return undef; } ############################################## @@ -1804,7 +1829,7 @@ __END__

Note: WeekdayTimer and MQTT2_DEVICE TYPE devices can not be used as 'master'.

- An other use case is the usage of categories 'Topics'. + An other use case is the usage of categories 'Topics'. To enable the feature the attribute 'useTopics' have to be set. Topics are e.q. winter, summer, holidays, party, and so on. A topic consists of different week profiles. Normally one profile for each thermostat. @@ -2012,10 +2037,13 @@ __END__
  • weekprofile
    - This attribute can be a userattr of supported modules of weekprofile to receive a specific profile with the - defined name at the restore_topic command. See topics for further information + This attribute can be a userattr of modules supported by weekprofile to receive a specific profile with the + defined weekprofile name at the restore_topic command. See topics for further information. +
  • + +
  • extraClientModules
    + This attribute can be used to add (space separated) additional client module names to the list of supported modules. The module has to support a "weekprofile" set command to indipendently react on this set command. weekprofile will hand over it's own instance name and a topic:weekprofile identifier to allow further processing (similar to WeekdayTimer or MQTT2_DEVICE) of the provided data. See also vitoconnect code for reference about the possibilities this feature offers.
  • - =end html @@ -2045,11 +2073,11 @@ __END__

    Hinweis: Geräte des Typs WeekdayTimer und MQTT2_DEVICE können nicht als 'Master-Gerät' verwendet werden.

    - Ein weiterer Anwendungsfall ist die Verwendung von Rubriken\Kategorien 'Topics'. + Ein weiterer Anwendungsfall ist die Verwendung von Rubriken\Kategorien 'Topics'. Hier sollte kein 'Master-Gerät' angegeben werden. Dieses Feature muss erst über das Attribut 'useTopics' aktiviert werden. Topics sind z.B. Winter, Sommer, Urlaub, Party, etc. Innerhalb einer Topic kann es mehrere Wochenprofile geben. Sinnvollerweise sollten es soviele wie Thermostate sein. - Über ein Userattribut 'weekprofile' im Thermostat wird ein Wochenprofile ohne Topicname angegeben. + Über ein Userattribut 'weekprofile' im Thermostat wird ein Wochenprofil ohne Topicname angegeben. Mittels 'restore_topic' wird dann das angebene Wochenprofil der Topic an das Thermostat übertragen. Somit kann man einfach zwischen den Topics wechseln und die Thermostate bekommen das passende Wochenprofil.

    @@ -2250,8 +2278,13 @@ __END__
  • weekprofile
    - Kann ein userattr eines unterstützten Moduls von weekprofile sein, um ein spezifisches Profil mit dem angegeben Namen - beim Befehl restore_topic zu empfangen. Siehe auch 'Topics'. + Kann ein userattr eines von weekprofile unterstützten Moduls sein, um ein spezifisches Wochenprofil mit dem angegeben Namen + beim Befehl restore_topic zu empfangen. Siehe auch 'Topics'. + +
  • + +
  • extraClientModules
    + Kann eine Leerzeichen-getrennte Liste weiterer Module enthalten, die dann von weekprofile als unterstützt erkannt werden. Die weiteren Module müssen ein "weekprofile" set Kommando kennen und dann selbst Code enthalten, der die empfangenen Informationen auswerten kann. weekprofile selbst übergibt nur den eigenen Namen und einen topic:Wochenprofil-Kenner, der dann - analog zu WeekdayTimer oder MQTT2_DEVICE - für die weitere Verarbeitung verwendet werden kann. Siehe hierzu auch den Code in vitoconnect, um einen Eindruck von den Möglichkeiten zu erhalten.