connects fhem to mqtt.
A single MQTT device can serve multiple MQTT_DEVICE and MQTT_BRIDGE clients.
Each MQTT_DEVICE acts as a bridge in between an fhem-device and mqtt.
Note: this module is based on Net::MQTT which needs to be installed from CPAN first.
Define
define <name> MQTT <ip:port> [<username>] [<password>]
Specifies the MQTT device.
Set
set <name> connect
(re-)connects the MQTT-device to the mqtt-broker
set <name> disconnect
disconnects the MQTT-device from the mqtt-broker
set <name> publish [qos:?] [retain:?] <topic> <message>
sends message to the specified topic
Attributes
keep-alive
sets the keep-alive time (in seconds).
attr <name> last-will [qos:?] [retain:?] <topic> <message>
Support for MQTT feature "last will"
example:
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>
Publish the specified message to a topic at connect / disconnect (counterpart to lastwill) and / or evaluation of Perl expression
If a Perl expression is provided, the message is sent only if expression returns true (for example, 1) or undef.
The following variables are passed to the expression at evaluation: $hash, $name, $qos, $retain, $topic, $message.
examples:
attr mqtt on-connect /topic/status connected
attr mqtt on-connect {Log3("abc",1,"on-connect")} /fhem/status connected
on-timeout
attr <name> on-timeout {Perl-expression}
evaluate the given Perl expression on timeout