diff --git a/fhem/FHEM/10_MQTT_GENERIC_BRIDGE.pm b/fhem/FHEM/10_MQTT_GENERIC_BRIDGE.pm index 2f10b7c13..e500af3ea 100644 --- a/fhem/FHEM/10_MQTT_GENERIC_BRIDGE.pm +++ b/fhem/FHEM/10_MQTT_GENERIC_BRIDGE.pm @@ -33,6 +33,10 @@ # 31.01.2021 1.3.1 # cleanup : Bereinigung der Konstruktionen wie my $... if / unless ... # (patch von Beta-User) +# bugfix : retain bei MQTT2 ohne Funktion (patch von Beta-User) +# added : Initialisierung beim Start für AttrTemplate (patch von Beta-User) +# added : Unterstützung für Attribut forceNEXT (patch von Beta-User) +# cleanup : Dokumentation (patch von Beta-User) # # 19.01.2021 1.3.0 # feature : supports attrTemplate (thanks to Beta-User) @@ -446,6 +450,7 @@ sub MQTT_GENERIC_BRIDGE_Initialize($) { CTRL_ATTR_NAME_GLOBAL_DEV_EXCLUDE.":textField-long ". "disable:1,0 ". "debug:0,1 ". + "forceNEXT:0,1 ". $main::readingFnAttributes; #main::LoadModule("MQTT"); @@ -656,6 +661,7 @@ sub Define() { # $hash->{subscribeExpr} = []; # } + ::AttrTemplate_Initialize() if $::init_done; # noetig hier beim Anlegen im laufendem Betrieb InternalTimer(1, \&firstInit, $hash); @@ -2460,7 +2466,7 @@ sub doPublish($$$$$$$$) { if (isIODevMQTT2($hash)){ #if ($hash->{+HELPER}->{+IO_DEV_TYPE} eq 'MQTT2_SERVER') { # TODO: publish MQTT2 # TODO qos / retain ? - $topic.=':r' if $retain; + $topic ='-r $topic' if $retain; IOWrite($hash, "publish", $topic.' '.$message); readingsSingleUpdate($hash,"transmission-state","outgoing publish sent",1); $hash->{+HELPER}->{+HS_PROP_NAME_OUTGOING_CNT}++; @@ -2821,6 +2827,7 @@ sub Parse($$) { my @instances = devspec2array("TYPE=MQTT_GENERIC_BRIDGE"); my @ret=(); + my $forceNext = 0; foreach my $dev (@instances) { my $hash = $defs{$dev}; # Name mit IODev vegleichen @@ -2841,6 +2848,7 @@ sub Parse($$) { next unless defined $fret; if( ref($fret) eq 'ARRAY' ) { push (@ret, @{$fret}); + $forceNext = 1 if AttrVal($hash->{NAME},'forceNEXT',0); #my @ret=@{$fret}; #unshift(@ret, "[NEXT]"); # damit weitere Geraetemodule ggf. aufgerufen werden #return @ret; @@ -2848,7 +2856,7 @@ sub Parse($$) { Log3($hash->{NAME},1,"MQTT_GENERIC_BRIDGE: [$hash->{NAME}] Parse ($iiodt : '$ioname'): internal error: onmessage returned an unexpected value: ".$fret); } } - unshift(@ret, "[NEXT]"); # damit weitere Geraetemodule ggf. aufgerufen werden + unshift(@ret, "[NEXT]") if !(@ret) || $forceNext; # damit weitere Geraetemodule ggf. aufgerufen werden return @ret; } @@ -2946,6 +2954,7 @@ sub onmessage($$$) { 1; =pod +=encoding utf8 =item [device] =item summary MQTT_GENERIC_BRIDGE acts as a bridge for any fhem-devices and mqtt-topics =begin html @@ -3066,13 +3075,6 @@ sub onmessage($$$) {

-
  • -

    globalSubscribe ! TODO - is currently not supported and may not be implemented at all!
    - Defines topics / flags for MQTT transmission. These are used if there are no suitable values in the respective device. - see mqttSubscribe. -

    -
  • -
  • globalTypeExclude
    Defines (device) types and readings that should not be considered in the transmission. @@ -3095,6 +3097,12 @@ sub onmessage($$$) {

    Example:
    attr <dev> globalDeviceExclude Test Bridge:transmission-state

  • + +
  • +

    forceNEXT
    + Only relevant for MQTT2_CLIENT or MQTT2_SERVER as IODev. If set to 1, MQTT_GENERIC_BRIDGE will forward incoming messages also to further client modules like MQTT2_DEVICE, even if the topic matches to one of the subscriptions of the controlled devices. By default, these messages will not be forwarded for better compability with autocreate feature on MQTT2_DEVICE. See also clientOrder attribute in MQTT2 IO-type commandrefs; setting this in one instance of MQTT_GENERIC _BRIDGE might affect others, too.

    +
  • +

    For the monitored devices, a list of the possible attributes is automatically extended by several further entries. They all begin with a prefix previously defined in the bridge. These attributes are used to configure the actual MQTT mapping.
    @@ -3349,13 +3357,13 @@ sub onmessage($$$) {

    MQTT_GENERIC_BRIDGE

    @@ -3398,7 +3406,7 @@ sub onmessage($$$) {

    Attribute:

    - =end html_DE =cut