-
Notifications
You must be signed in to change notification settings - Fork 130
Items mqtt
Awaiting contributions
A MQTT Interface and Item module for Misterhouse
This is the base interface class for Message Queue Telemetry Transport (MQTT) interface for use with any MQTT service, see (http://mqtt.org/) and (http//test.mosquitto.org/) for a broker and test service.
The current version supports the following wildcards
- single level wildcards e.g. +/devicename/+
- trailing multilevel wildcards e.g. stat/#
If the Last Will and Testament (LWT) parameters are set in mh.ini
, it will connect with these and you need to send an online message when MisterHouse starts up e.g.
Example:
print_log( "sending LWT online message topic="
. $config_parms{mqtt_LWT_topic}
. " payload="
. "online" );
$mqtt_1->pub_msg(
message_type => MQTT_PUBLISH,
retain => 1,
topic => $config_parms{mqtt_LWT_topic},
message => "online"
);
CODE, require mqtt; #noloop
# address of the mqtt broker and port
mqtt_host=192.168.1.6
mqtt_server_port=1883
# topic to subscribe to
mqtt_topic=#
# mqtt Last Will and testament
mqtt_LWT_topic=tele/Misterhouse/LWT
mqtt_LWT_payload=offline
# debug
mqtt_debug=0
# mqtt_user=user # (optional)
# mqtt_password=password # (optional)
# mqtt_keepalive=120 # (optional)
# define the broker
MQTT_BROKER, mqtt_1
# mqtt devic (tasmota in this case)
# MQTT_DEVICE, devicename, groups , broker, topic
MQTT_DEVICE, Workshop_cutout, Stay_off_at_night , mqtt_1, cmnd/Workshop_cutout/POWER
CODE, $Workshop_cutout->{states_casesensitive} = 1;
NOTE: by default, the Generic_item->set
method converts values to lower case. If you are expecting to receive the same case as the MQTT messages, you need to set states_casesensitive
for this device e.g.
$Workshop_cutout->{states_casesensitive} = 1;
or in items.mht
as above.
Neil Cherry [email protected] Based loosely on the UPMPIM.pm and SqueezeCLI.pm code - Jason Sharpee (UPB) - Lieven Hollevoet (SqueezeCLI)
Controlling Tasmota from misterhouse using mqtt
Trailing wildcards