Home Assistant – Tasmota

Home Assistant is an open-source home automation solution that puts local control and privacy first.

Tasmota communicates with Home Assistant via MQTT. Before proceeding, make sure MQTT is properly configured in Home Assistant and Tasmota.

Home Assistant can add Tasmota devices with :

  • Official Tasmota integration – preferred automatic instant entity detection.
  • Manual configuration by editing the configuration.yaml file – recommended for marginal use cases, that are TuyaMCU fan units.

Tasmot Integration

Open your Home Assistant instance and start setting up your new integration.

Setting up Home Assistant integration will automatically detect all new Tasmota devices with SetOption19 0.

All Tasmota devices are listed on their own Tasmota card in Home Assistant’s Configure – Integrations menu.

Device name is used by Tasmota for naming devices in Tasmota Integration whereas it uses FriendlyName<x> for power outputs.

Supported Entities:

  1. Light: Single channel dimmer, RGB, RGB  with color temperature control and RGB  with white control are supported.
  1. A relay as a switch object: With SetOption30 1 all relays and devices are added as light objects.
  2. Sensors as sensory objects: When SetOption114 is 1, switch to either a binary_sensor object or an automation trigger depending on the SwitchMode used.
  3. Button used as automation trigger when SetOption73 is enabled
  4. Shutter as cover. Currently, only Shutter Modes 1-4 are supported, Shutter Mode 5 and Tuya Shutter are not supported.
  5. A device configured with iFan02 or iFan03 as the fan object. TuyaMCU fans are not supported. Each discovered device adds 8 disabled sensors by default.

Switch on what you need. It cannot be deleted and will  be added again on restart.

Removing Devices

As long as Home Assistant support is enabled in the Tasmota binary, you can’t. Disable the device in Home Assistant instead. If you remove your Tasmota device from Home Assistant while it’s still active, everything will eventually be rediscovered.

Supplemental custom discovery message

You can use MQTT discovery in HA to add sensors and other objects not discovered by the Tasmota integration and associate them with  already discovered devices.

Add the following device ID –

,”device”:{“connections”:[[“mac”,”%macaddr%”]]} when creating a JSON MQTT discovery. Where %macaddr% is the mac address of the device.

When used in rules, the %macaddr% variable is automatically substituted.

There are Home Assistant blueprints for specific device types on GitHub to create the required objects. Find the icon in the template to bring configuration automation to you with a single click.

Examples of creating custom discovery messages:

  • RFID Tag
  • PIR sensor
  • TuyaMCU Air Fryer
  • TuyaMCU Heater

Editing configuration.yaml

To manually add devices, you can edit the configuration.yaml file and add the appropriate  yaml code blocks to the appropriate sections. The advantage of manually configuring your device is that you still have control over all aspects of the configuration. Structure and procedures for setting up the assistant.  Copying the given examples directly into the configuration.yaml file probably won’t work for you.

If you are using a localized (non-English) version, check the  spelling and case of values –

  • ‘payload_available’
  • ‘payload_not_available’
  • ‘payload_on’
  • ‘payload_off’

Switches

Add  Home Assistant using the MQTT switch integration.

required command –

SetOption59 1 – You can send tele/%topic%/STATE commands related to power and lighting for faster updates.

Lights

Add Home Assistant with MQTT Light integration.

All configurations require SetOption59 1 –  tele/%topic%/STATE can be sent to POWER and lighting related commands.

Some additional commands –

Fade On – Makes the transition smoother.

Speed ​​5 – set transition speed.

Sensor

Add  Home Assistant with MQTT sensor integration.

The sensor transmits data at set intervals defined by TelePeriod (every 5 minutes by default).

Check the sensor name in the Tasmota console and change it accordingly. This example uses the DHT22 sensor.

Power Monitoring

Add  Home Assistant with MQTT sensor integration.

The power control sensor sends data at set intervals defined by TelePeriod (every 5 minutes by default).

You’ll need multiple sensors to get all the data from Home Assistant, and you can later group them however you like in the Lovelace user interface.

Binary Sensors

Add in Home Assistant using the MQTT Binary Sensor integration.

Fans

Here you should include the Home Assistant with the MQTT Fan integration.

Covers

Here you should include in the Home Assistant with the MQTT Cover integration.

Device Specific

For the shutter position to persist in Home Assistant through device reboots, you must execute PowerRetain 1.

Zigbee Devices

This configuration is for dimmable lights reporting  0xE1F9 using endpoint 1, cluster 8 for brightness. The ZbRead part of the template is required to keep the brightness values ​​up to date.

Useful Automation

Wi-Fi signal quality can be added as a setting to the previous configuration by adding this section to the existing yaml configuration.

The Tasmota device state may get out of sync with Home Assistant if you restart the MQTT broker or Home Assistant, or if WiFi is disabled. Use this automation to sync your devices, including their power state, as soon as you start Home Assistant.

Add this block to your automation with  %topic% to synchronize the state of one TuyaMCU unit. !!!  You can use error tasmotas, but SerialSend can cause problems on other devices, so proceed with caution.

Synchronize the state of Zigbee devices. Add this block with  %topic% and  Zigbee device name, endpoint and cluster.

MQTT Discovery REMOVED

Home Assistant has a feature called MQTT Search. With MQTT discovery, no user interaction or configuration file editing is required to add a new device to Home Assistant. Most changes are automatically updated by HA.  Enable auto-discovery~

Enable auto-discovery on your device using the following command: Set option 19 1.

When autodiscovery is enabled, stored MQTT messages beginning with the subject “homeassistant/” are sent to the broker. This message contains the device configuration, which  Home Assistant uses to automatically add the device to the MQTT integration. Tasmota uses DeviceName to identify the device in the Home Assistant MQTT integration and FriendlyName to identify the power output (switch or light object in HA).

When changing some settings, you may need to reboot or use SetOption19 1 again to see the new changes in Home Assistant.

Setup complete

All auto-discovered objects are displayed under “Configuration” -> “Integration” -> “MQTT Map”.

Objects are grouped under devices identified by DeviceName and identified by Tasmota as “Manufacturer”.

You can further customize your device in Home Assistant by clicking on the item name.

Enabling discovery automatically changes some SetOptions to match the new configuration.

  • SetOption4 to 0: Always return MQTT responses as RESULTs rather than %COMMAND% titles.
  • Set SetOption17 to 1: Display colors as comma-decimal strings instead of hexadecimal numbers.
  • Set parameter 59 to 1: Send tele/%topic%/STATE in addition to stat/%topic%/RESULT for all commands that turn on status, power, and lights.
Troubleshooting

Make sure Tasmota and Home Assistant are communicating properly.

  • Open your Home Assistant instance and display the MQTT configuration panel.
  • Click the button above or go to “Configuration” – “Integration” in the Home Assistant web interface, find your MQTT card and click “Configure”.
  • Subscribe to tele/%topic%/STATE and click START LISTENING.
  • You should see a JSON response from your device within 5 minutes.
  • To test a relay or light control, enter cmnd/%topic%/POWER with a payload switch or 2 as the package topic post.
  • After clicking PUBLISH, the device should change state and receive a JSON response.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top