From 209738570ef34ba1c93d5629410058d1ed731d24 Mon Sep 17 00:00:00 2001 From: eisler Date: Mon, 19 Feb 2018 18:26:50 +0000 Subject: [PATCH] 00_MQTT: new attribute "client-id" git-svn-id: https://svn.fhem.de/fhem/trunk@16223 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/00_MQTT.pm | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index c2607654a..777cf6f59 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # 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: 00_MQTT: new attribute "client-id" - feature: 93_DbRep: V7.13.0, changeValue may use perlcode {} as "new string" - feature: 93_DbRep: V7.12.0, compression of dumpfile, restore of compressed files possible diff --git a/fhem/FHEM/00_MQTT.pm b/fhem/FHEM/00_MQTT.pm index c02cd3f0f..123978b23 100644 --- a/fhem/FHEM/00_MQTT.pm +++ b/fhem/FHEM/00_MQTT.pm @@ -59,7 +59,7 @@ sub MQTT_Initialize($) { $hash->{NotifyFn} = "MQTT::Notify"; $hash->{AttrFn} = "MQTT::Attr"; - $hash->{AttrList} = "keep-alive "."last-will "."on-connect on-disconnect on-timeout ".$main::readingFnAttributes; + $hash->{AttrList} = "keep-alive "."last-will client-id "."on-connect on-disconnect on-timeout ".$main::readingFnAttributes; } package MQTT; @@ -564,9 +564,10 @@ sub send_connect($) { my $pass = getKeyValue($name."_pass"); my $lw = AttrVal($name,"last-will",undef); + my $clientId = AttrVal($name,"client-id",undef); my ($willqos, $willretain,$willtopic, $willmessage) = parsePublishCmdStr($lw); - return send_message($hash, message_type => MQTT_CONNECT, keep_alive_timer => $hash->{timeout}, user_name => $user, password => $pass, will_topic => $willtopic, will_message => $willmessage, will_retain => $willretain, will_qos => $willqos); + return send_message($hash, message_type => MQTT_CONNECT, keep_alive_timer => $hash->{timeout}, user_name => $user, password => $pass, client_id=>$clientId, will_topic => $willtopic, will_message => $willmessage, will_retain => $willretain, will_qos => $willqos); }; sub send_publish($@) { @@ -878,6 +879,14 @@ sub client_stop($) { attr mqtt last-will /fhem/status crashed

+
  • +

    attr <name> client-id client id
    + redefines client id +

    +

    example:
    + attr mqtt client-id fhem1234567 +

    +
  • on-connect, on-disconnect
    attr <name> on-connect {Perl-expression} <topic> <message>