Skip to content

MQTT \ Home Assistant

Resinchem edited this page Sep 10, 2021 · 9 revisions

MQTT and Home Assistant

MQTT

The following is a list of the current MQTT topics and valid payloads supported by the Tailwind API and Tailwind2MQTT bridge. The values MQTT_TOPIC_SUB and MQTT_TOPIC_PUB will be substituted with the topics you define in the settings file. See the Settings and Credentials page for more information on defining your own MQTT topics.

Command Topics - issued TO the bridge to control Tailwind

TOPIC PAYLOAD NOTES
MQTT_TOPIC_SUB/opendoor 1, 2 or 3 Open corresponding Tailwind door
MQTT_TOPIC_SUB/closedoor 1, 2 or 3 Close corresponding Tailwind door
MQTT_TOPIC_SUB/toggledoor 1, 2 or 3 Toggle corresponding Tailwind door (open if closed, close if open)

State Topics - sent FROM the bridge to MQTT broker

TOPIC PAYLOAD NOTES
MQTT_TOPIC_PUB/mqtt connected Published upon boot connection to MQTT. Generally used for troubleshooting
MQTT_TOPIC_PUB/lastresult OK, FAILED or INVALID Returns the result of the last command. OK if successful, FAILED if Tailwind web server does not return '200' or the API does not return the proper result code. INVALID if an invalid payload was passed.
MQTT_TOPIC_PUB/statuscode 0-7 Returns the Tailwind API raw status code from a command
MQTT_TOPIC_PUB/door1/state 'on' or 'off' 'on' represents an open door from an Home Assistant binary_sensor perspective and 'off' represents closed.
MQTT_TOPIC_PUB/door2/state 'on' or 'off' 'on' open, 'off' closed.
MQTT_TOPIC_PUB/door3/state 'on' or 'off' 'on' open, 'off' closed.

Home Assistant

MQTT Discovery

Beginning with release v0.43, if Home Assistant MQTT Discovery is enabled in your settings (ha_discovery = true;), the discovery process will create all available sensors in Home Assistant without the need to manually define the sensors in YAML. Release 0.45 adds switches to control the doors (open/close). When enabled and the bridge is rebooted, the follow entities will appear in Home Assistant:

Sensors and States

Entity_id State values
binary_sensor.tailwind_door1 on (open) or off (closed)
binary_sensor.tailwind_door2 on (open) or off (closed)
binary_sensor.tailwind_door3 on (open) or off (closed)
sensor.tailwind_mqtt_status connected once connected to broker
sensor.tailwind_last_result OK, FAILED or INVALID (see above)
sensor.tailwind_status_code 0-7 (see above)

Switches and Control States

Entity_id Control and State
switch.tailwind_door1 Switch on (open), switch off (close)
switch.tailwind_door2 Switch on (open), switch off (close)
switch.tailwind_door3 Switch on (open), switch off (close)

If you do not want all of these entities (for example, you only have one door and don't need sensors or switches for the other doors), you can either disable the entity in Home Assistant, or you can disable MQTT Discovery and define your own sensors via YAML. Note: Binary sensors and switches that do not have a corresponding physical door attached to Tailwind will always show a state of 'on' (open).

If you wish to disable MQTT Discover after the entities have already been created, just set ha_discovery = false; in the Settings.h file and upload the sketch to the bridge again. Upon boot, the entities will be removed from Home Assistant. If you used these entities in any scripts, automations or Lovelace cards, you will need to remove or update those items as well.

Manually creating sensors

If you want more control over the entities, you may manually create MQTT sensors via yaml.

You do not need to create sensors for every possible MQTT topic. For example, if you only have a single garage door connected to Tailwind as 'Door 1', there is no need to create binary sensors for doors 2 and 3. Similarly, you do not need to create sensors for other topics like statuscode unless you want to see or use that in some manner.

At a minimum, you'll probably want a binary sensor for the state of each door you have connected to Tailwind. For door control it is recommended that a script be created for each of the three commands: Open, Close and Toggle. See the \homeassistant folder for yaml examples of sensors, scripts and Lovelace cards.

Note: You can use both MQTT Discovery and create your own sensors. You may want to do this if you want to create special sensors based on templates or for any other reason. The only restriction is that your manually created sensors MUST have a different entity_id than the ones create via MQTT Discovery.