Home Assistant (Hass) is an open source home automation solution that puts local control and privacy first.
Tasmota communicates with Home Assistant using MQTT. Before going any further, make sure MQTT is properly set up in Home Assistant and in Tasmota.
First, test if the two can communicate.
In Home Assistant web UI go to Developer Tools - MQTT. Subscribe to tele/topic%/STATE
and click START LISTENING. You should see a JSON response from your device.
To test control of a relay or light, as Publish a packet topic enter cmnd/%topic%/POWER
with payload toggle
. When you click PUBLISH your device should switch state and a JSON response will be visible in Listen to a topic window.
Home Assistant has two avenues of adding Tasmota devices:
- Using MQTT discovery
- Adding by editing configuration.yaml
Note
After every change to the configuration file you'll need to restart Home Assistant to make it aware of the changes.
If you don't want to use MQTT discovery, skip to Manual Config
Home Assistant has a feature called MQTT discovery. With MQTT discovery no user interaction or configuration file editing is needed to add new devices in Home Assistant.
Automatic discovery is currently supported for
Announced to Home Assistant as MQTT Switch.
To make a relay discovered as "light" in Home Assistant use command SetOption30 1
Alternatively you can configure it manually using Light Switch integration.
Announced to Home Assistant as MQTT Light.
Announced to Home Assistant as MQTT Light with a single channel used for dimming.
Announced to Home Assistant as MQTT Binary Sensor.
To have buttons discovered ButtonTopic
must be set to 0
(default value) and it will automatically start to listen and publish using %topic%/stat/BUTTON<x>
topic.
When using with default Tasmota setting the sensor in Home Assistant will show ON
for 1 second
when pressed, then it will automatically turn to OFF
.
SwitchMode
default for buttons and switches is Switchmode 0
(TOGGLE). To change the behavior, SwitchMode
must be changed. For example setting up a switch to SwitchMode 1
(follow) will create a switch with ON and OFF payloads.
Announced to Home Assistant as MQTT Binary Sensor.
To have switches discovered SwitchTopic
must be set to 0
(default value) and it will automatically start to listen and publish using %topic%/stat/SWITCH<x>
topic.
When using with default Tasmota setting the sensor in Home Assistant will follow the status of the switch.
SwitchMode
default for buttons and switches is Switchmode 0
(TOGGLE). To change the behavior, SwitchMode
must be changed. For example setting up a switch to SwitchMode 1
(follow) will create a switch with ON and OFF payloads.
Types of devices not listed above (fans, covers, etc) require manual configuration
For a Tasmota device to be automatically discovered by Home Assistant you need to enable MQTT discovery with command:
SetOption19 1
After the automatic discovery feature is enabled a retained MQTT message starting with topic "homeassistant/" is sent to the broker. That message contains your device configuration which will be picked up and used by Home Assistant to automatically add your device.
!>Device FullTopic will become %topic%/%prefix%/<command>
(cmnd/tasmota/POWER
to tasmota/cmnd/POWER
) and cannot be changed as long as SetOption19 1
is active.
Enabling discovery will automatically change some SetOptions to suit the new configuration:
SetOption4
to 0
Return MQTT response always as RESULT
and not as %COMMAND% topic
SetOption17
to 1
Show Color as a comma-separated decimal string instead of hexadecimal
SetOption59
to 1
Send tele/%topic%/STATE
in addition to stat/%topic%/RESULT
for commands State
, Power
and any command causing a light to be turned on.
Note
For every change you made on your device configuration you will need a reboot or use SetOption19 1
again to see the changes under Home Assistant.
Warning
Please be advised that not all sensors can be correctly rendered under Home Assistant. In those cases a fallback function will be used to create a generic sensor.
To disable MQTT discovery and remove the retained message, execute SetOption19 0
.
The "homeassistant/" topic is removed from Home Assistant and MQTT broker.
!> Device FullTopic will not revert to defaults. You have to manually change the structure back to %prefix%/%topic%/
using Configure - MQTT Configuration page in the webUI or FullTopic
command.
All automatically discovered entities will show up under:
Configuration -> Integrations -> Configured -> MQTT
The entities are grouped by hardware, example for a Sonoff Basic:
By clicking on one of the entities, and then on the cog wheel, name in Home Assistant and entity_id
can be customized:
For every device discovered with SetOption19
an informative sensor will be created automatically:
Home Assistant (Hass) is an open-source home automation platform running on Python 3.
The advantage of manually configuring a device is that you maintain control of all aspects of the configuration.
Home Assistant configuration is done by editing the configuration.yaml
file.
[!DANGER] All the configurations are just examples.
You need to be familiar with Home Assistant's configuration structure and procedures.
Straight copy paste of the given examples into configuration.yaml will not work for you.
If you are using a localized (non-english) version be sure to check the correct spelling and cases for values:
- 'payload_available'
- 'payload_not_available'
- 'payload_on'
- 'payload_off'
Tip
If you want the power states to be persistent in Tasmota and Home Assistant set PowerRetain 1
instead of using retain: true
in Home Assistant
Add in Home Assistant using the MQTT Switch integration.
Required Commands
SetOption59 1
- enables sending of tele/%topic%/STATE on POWER and light related commands
switch:
- platform: mqtt
name: "Tasmota Switch"
state_topic: "stat/tasmota/RESULT"
value_template: "{{ value_json.POWER }}"
command_topic: "cmnd/tasmota/POWER"
payload_on: "ON"
payload_off: "OFF"
availability_topic: "tele/tasmota/LWT"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
retain: false
When a device has more than one relay you need to create a new switch for each relay. For each relay use corresponding POWER<x> (POWER1, POWER2, etc) or if SetOption26 is enabled)
switch:
- platform: mqtt
name: "Tasmota Switch 1"
state_topic: "stat/tasmota/RESULT"
value_template: "{{ value_json.POWER1 }}"
command_topic: "cmnd/tasmota/POWER1"
payload_on: "ON"
payload_off: "OFF"
availability_topic: "tele/tasmota/LWT"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
retain: false
- platform: mqtt
name: "Tasmota Switch 2"
state_topic: "stat/tasmota/RESULT"
value_template: "{{ value_json.POWER2 }}"
command_topic: "cmnd/tasmota/POWER2"
payload_on: "ON"
payload_off: "OFF"
availability_topic: "tele/tasmota/LWT"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
retain: false
- platform: mqtt
name: "Tasmota Switch 3"
state_topic: "stat/tasmota/RESULT"
value_template: "{{ value_json.POWER3 }}"
command_topic: "cmnd/tasmota/POWER3"
payload_on: "ON"
payload_off: "OFF"
availability_topic: "tele/tasmota/LWT"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
retain: false
Used for dimmers and dimmable lights (single channel lights).
light:
- platform: mqtt
name: "Dimmer"
command_topic: "cmnd/tasmota/POWER"
state_topic: "tele/tasmota/STATE"
state_value_template: "{{value_json.POWER}}"
availability_topic: "tele/tasmota/LWT"
brightness_command_topic: "cmnd/tasmota/Dimmer"
brightness_state_topic: "tele/tasmota/STATE"
brightness_scale: 100
on_command_type: "brightness"
brightness_value_template: "{{value_json.Dimmer}}"
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
retain: false
Tip
If you are using your device to control a light, you may want to use MQTT Light
integration instead.
Simply replace switch:
with light:
in the configuration keeping everything else the same.
Add in Home Assistant using the MQTT Light integration.
Required Commands
SetOption17 1
- enables decimal colors
SetOption59 1
- enables sending of tele/%topic%/STATE on POWER and light related commands
Optional Commands
Fade on
- makes transitions smoother
Speed 5
- sets transition speed
Used for dimmers and dimmable lights (single channel lights).
light:
- platform: mqtt
name: "Dimmer"
command_topic: "cmnd/tasmota/POWER"
state_topic: "tele/tasmota/STATE"
state_value_template: "{{value_json.POWER}}"
availability_topic: "tele/tasmota/LWT"
brightness_command_topic: "cmnd/tasmota/Dimmer"
brightness_state_topic: "tele/tasmota/STATE"
brightness_scale: 100
on_command_type: "brightness"
brightness_value_template: "{{value_json.Dimmer}}"
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
retain: false
light:
- platform: mqtt
name: "RGB Light"
command_topic: "cmnd/tasmota/POWER"
state_topic: "tele/tasmota/STATE"
state_value_template: "{{value_json.POWER}}"
availability_topic: "tele/tasmota/LWT"
brightness_command_topic: "cmnd/tasmota/Dimmer"
brightness_state_topic: "tele/tasmota/STATE"
brightness_scale: 100
on_command_type: "brightness"
brightness_value_template: "{{value_json.Dimmer}}"
rgb_command_topic: "cmnd/tasmota/Color2"
rgb_state_topic: "tele/tasmota/STATE"
rgb_value_template: "{{value_json.Color.split(',')[0:3]|join(',')}}"
effect_command_topic: "cmnd/tasmota/Scheme"
effect_state_topic: "tele/tasmota/STATE"
effect_value_template: "{{value_json.Scheme}}"
effect_list:
- 0
- 1
- 2
- 3
- 4
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
retain: false
light:
- platform: mqtt
name: "RGB+W Light"
command_topic: "cmnd/tasmota/POWER"
state_topic: "tele/tasmota/STATE"
state_value_template: "{{value_json.POWER}}"
availability_topic: "tele/tasmota/LWT"
brightness_command_topic: "cmnd/tasmota/Dimmer"
brightness_state_topic: "tele/tasmota/STATE"
brightness_scale: 100
on_command_type: "brightness"
brightness_value_template: "{{value_json.Dimmer}}"
white_value_state_topic: "tele/tasmota/STATE"
white_value_command_topic: "cmnd/tasmota/White"
white_value_scale: 100
white_value_template: "{{ value_json.Channel[3] }}"
rgb_command_topic: "cmnd/tasmota/Color2"
rgb_state_topic: "tele/tasmota/STATE"
rgb_value_template: "{{value_json.Color.split(',')[0:3]|join(',')}}"
effect_command_topic: "cmnd/tasmota/Scheme"
effect_state_topic: "tele/tasmota/STATE"
effect_value_template: "{{value_json.Scheme}}"
effect_list:
- 0
- 1
- 2
- 3
- 4
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
retain: false
Also known as RGBWW or 5 channel lights
light:
- platform: mqtt
name: "RGBCCT Light"
command_topic: "cmnd/tasmota/POWER"
state_topic: "tele/tasmota/STATE"
state_value_template: "{{value_json.POWER}}"
availability_topic: "tele/tasmota/LWT"
brightness_command_topic: "cmnd/tasmota/Dimmer"
brightness_state_topic: "tele/tasmota/STATE"
brightness_scale: 100
on_command_type: "brightness"
brightness_value_template: "{{value_json.Dimmer}}"
color_temp_command_topic: "cmnd/tasmota/CT"
color_temp_state_topic: "tele/tasmota/STATE"
color_temp_value_template: "{{value_json.CT}}"
rgb_command_topic: "cmnd/tasmota/Color2"
rgb_state_topic: "tele/tasmota/STATE"
rgb_value_template: "{{value_json.Color.split(',')[0:3]|join(',')}}"
effect_command_topic: "cmnd/tasmota/Scheme"
effect_state_topic: "tele/tasmota/STATE"
effect_value_template: "{{value_json.Scheme}}"
effect_list:
- 0
- 1
- 2
- 3
- 4
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
retain: false
Applies only to WS281x lights.
light:
- platform: mqtt
name: "Addressable LED"
command_topic: "cmnd/tasmota/POWER"
state_topic: "stat/tasmota/STATE"
state_value_template: "{{value_json.POWER}}"
availability_topic: "tele/tasmota/LWT"
brightness_command_topic: "cmnd/tasmota/Dimmer"
brightness_state_topic: "stat/tasmota/STATE"
brightness_scale: 100
on_command_type: "brightness"
brightness_value_template: "{{value_json.Dimmer}}"
rgb_command_topic: "cmnd/tasmota/Color2"
rgb_state_topic: "tele/tasmota/STATE"
rgb_value_template: "{{value_json.Color.split(',')[0:3]|join(',')}}"
effect_command_topic: "cmnd/tasmota/Scheme"
effect_state_topic: "stat/tasmota/STATE"
effect_value_template: "{{value_json.Scheme}}"
effect_list:
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
retain: false
If you don't want to use SetOption17 1
you can change
rgb_value_template: "{{value_json.Color.split(',')[0:3]|join(',')}}"
to
rgb_value_template: "{% if value_json.Color is defined %}{{ (value_json.Color[0:2]|int(base=16),value_json.Color[2:4]|int(base=16),value_json.Color[4:6]|int(base=16)) | join(',')}}{% endif %}"
Add in Home Assistant using the MQTT Sensor integration.
A sensor will send its data in set intervals defined by TelePeriod
(default every 5 minutes).
Check your sensor name in Tasmota and change accordingly. This example uses the DHT22 sensor.
sensor:
- platform: mqtt
name: "Tasmota Temperature"
state_topic: "tele/tasmota/SENSOR"
value_template: "{{ value_json['DHT22'].Temperature }}"
unit_of_measurement: "°C" # "F" if using Fahrenheit
availability_topic: "tele/tasmota/LWT"
payload_available: "Online"
payload_not_available: "Offline"
device_class: temperature
Check your sensor name in Tasmota and change accordingly. This example uses the DHT22 sensor.
sensor:
- platform: mqtt
name: "Tasmota Humidity"
state_topic: "tele/tasmota/SENSOR"
value_template: "{{ value_json['DHT22'].Humidity }}"
unit_of_measurement: "%"
availability_topic: "tele/tasmota/LWT"
payload_available: "Online"
payload_not_available: "Offline"
device_class: humidity
Check your sensor name in Tasmota and change accordingly. This example uses the BMP280 sensor.
sensor:
- platform: mqtt
name: "Tasmota Pressure"
state_topic: "tele/tasmota/SENSOR"
value_template: "{{ value_json.BMP280.Pressure }}"
unit_of_measurement: "hPa"
device_class: pressure
Change unit_of_measurement to "mmHg"
if SetOption24 1
Monitor the relative Wi-Fi signal quality of a device.
sensor:
- platform: mqtt
name: "Tasmota Wi-Fi Quality"
state_topic: "tele/tasmota/STATE"
unit_of_measurement: "%"
value_template: "{{value_json['Wifi'].RSSI }}"
availability_topic: "tele/tasmota/LWT"
payload_available: "Online"
payload_not_available: "Offline"
device_class: signal_strength
Add in Home Assistant using the MQTT Sensor integration.
Power monitoring sensors will send their data in set intervals defined by TelePeriod
(default every 5 minutes).
To get all the data in Home Assistant requires multiple sensors which you can later group to your liking in Lovelace UI
sensor:
- platform: mqtt
name: "Energy Today"
state_topic: "tele/tasmota/SENSOR"
value_template: '{{ value_json["ENERGY"]["Today"] }}'
unit_of_measurement: "kWh"
- platform: mqtt
name: "Power"
state_topic: "tele/tasmota/SENSOR"
value_template: '{{ value_json["ENERGY"]["Power"] }}'
unit_of_measurement: "W"
- platform: mqtt
name: "Voltage"
state_topic: "tele/tasmota/SENSOR"
value_template: '{{ value_json["ENERGY"]["Voltage"] }}'
unit_of_measurement: "V"
- platform: mqtt
name: "Current"
state_topic: "tele/tasmota/SENSOR"
value_template: '{{ value_json["ENERGY"]["Current"] }}'
unit_of_measurement: "A"
Tip
For additional sensors use "Total";"Yesterday";"Period","ApparentPower","ReactivePower";"Factor" in value_template
string
Video tutorial on a power monitoring plug setup by Digiblur
Add in Home Assistant using the MQTT Binary Sensor integration.
Used for a configured PIR Sensor and requires this rule:
Required Commands
Rule1 on Switch1#State=1 do Publish stat/hall/MOTION ON endon on Switch1#State=1 do Publish stat/hall/MOTION OFF endon
Rule1 1
binary_sensor:
- platform: mqtt
name: "Tasmota Motion Sensor"
state_topic: "stat/tasmota/MOTION"
availability_topic: "tele/tasmota/LWT"
payload_available: "Online"
payload_not_available: "Offline"
device_class: motion
qos: 1
Requires a reed switch configured in Tasmota.
Required Commands
Rule1 on Switch1#State=1 do Publish stat/hall/MOTION ON endon on Switch1#State=1 do Publish stat/hall/MOTION OFF endon
Rule1 1
binary_sensor:
- platform: mqtt
name: "Tasmota Motion Sensor"
state_topic: "stat/tasmota/MOTION"
availability_topic: "tele/tasmota/LWT"
payload_available: "Online"
payload_not_available: "Offline"
device_class: door # also: window, garage_door or opening
qos: 1
An RF door sensor configured with an RF receiver in Tasmota.
binary_sensor:
- platform: mqtt
name: "RF bridge rfkey"
payload_on: "1"
payload_off: "0"
device_class: opening
state_topic: "tele/tasmota/RESULT"
value_template: '{{ value_json.RfReceived.RfKey }}'
Add in Home Assistant using the MQTT Fan integration.
Derived from #2839 by @kbickar and @finity69x2
# Example configuration.yaml entry
fan:
- platform: mqtt
name: "Tasmota Fan"
command_topic: "cmnd/tasmota/FanSpeed"
speed_command_topic: "cmnd/tasmota/FanSpeed"
state_topic: "stat/tasmota/RESULT"
speed_state_topic: "stat/tasmota/RESULT"
state_value_template: >
{% if value_json.FanSpeed is defined %}
{% if value_json.FanSpeed == 0 -%}0{%- elif value_json.FanSpeed > 0 -%}4{%- endif %}
{% else %}
{% if states.fan.tasmota.state == 'off' -%}0{%- elif states.fan.tasmota.state == 'on' -%}4{%- endif %}
{% endif %}
speed_value_template: "{{ value_json.FanSpeed }}"
availability_topic: tele/tasmota/LWT
payload_off: "0"
payload_on: "4"
payload_low_speed: "1"
payload_medium_speed: "2"
payload_high_speed: "3"
payload_available: Online
payload_not_available: Offline
speeds:
- off
- low
- medium
- high
Combination of configs found in issue #2839 and Home Assistant forum thread Sonoff IFan02 (Tasmota) MQTT Fan.
fan:
- platform: mqtt
name: "Pat Ceiling Fan"
state_topic: "stat/ifan02/RESULT"
speed_state_topic: "stat/ifan02/RESULT"
state_value_template: >
{% if value_json.FanSpeed is defined %}
{% if value_json.FanSpeed == 0 -%}0{%- elif value_json.FanSpeed > 0 -%}2{%- endif %}
{% else %}
{% if states.fan.pat_ceiling_fan.state == 'off' -%}0{%- elif states.fan.pat_ceiling_fan.state == 'on' -%}2{%- endif %}
{% endif %}
speed_value_template: "{{ value_json.FanSpeed }}"
availability_topic: tele/ifan02/LWT
payload_available: Online
payload_not_available: Offline
speed_command_topic: "cmnd/ifan02/FanSpeed"
payload_low_speed: "1"
payload_medium_speed: "2"
payload_high_speed: "3"
command_topic: "cmnd/ifan02/FanSpeed"
payload_off: "0"
payload_on: "2"
qos: 1
retain: false
speeds:
- low
- medium
- high
light:
- platform: mqtt
name: "Pat Ceiling Light"
state_topic: "tele/ifan02/STATE"
value_template: "{{ value_json.POWER }}"
command_topic: "cmnd/ifan02/POWER"
availability_topic: "tele/ifan02/LWT"
qos: 1
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
retain: false
Configure the device as Sonoff S31, and run:
SetOption4 1
SetOption59 1
switch:
- platform: mqtt
name: "s31 power"
state_topic: "tele/s31/STATE"
value_template: "{{ value_json.POWER }}"
command_topic: "cmnd/s31/POWER"
availability_topic: "tele/s31/LWT"
qos: 1
payload_on: "ON"
payload_off: "OFF"
payload_available: "Online"
payload_not_available: "Offline"
retain: false
sensor:
- platform: mqtt
name: "s31 Voltage"
state_topic: "tele/s31/SENSOR"
value_template: "{{ value_json['ENERGY'].Voltage }}"
unit_of_measurement: "V"
availability_topic: "tele/s31/LWT"
qos: 1
payload_available: "Online"
payload_not_available: "Offline"
- platform: mqtt
name: "s31 Current"
state_topic: "tele/s31/SENSOR"
value_template: "{{ value_json['ENERGY'].Current | round(2) }}"
unit_of_measurement: "A"
availability_topic: "tele/s31/LWT"
qos: 1
payload_available: "Online"
payload_not_available: "Offline"
- platform: mqtt
name: "s31 Power"
state_topic: "tele/s31/SENSOR"
value_template: "{{ value_json['ENERGY'].Power }}"
unit_of_measurement: "W"
availability_topic: "tele/s31/LWT"
qos: 1
payload_available: "Online"
payload_not_available: "Offline"
device_class: power
- platform: mqtt
name: "s31 Power Factor"
state_topic: "tele/s31/SENSOR"
value_template: "{{ value_json['ENERGY'].Factor }}"
availability_topic: "tele/s31/LWT"
qos: 1
payload_available: "Online"
payload_not_available: "Offline"
- platform: mqtt
name: "s31 Energy Today"
state_topic: "tele/s31/SENSOR"
value_template: "{{ value_json['ENERGY'].Today }}"
unit_of_measurement: "kWh"
availability_topic: "tele/s31/LWT"
qos: 1
payload_available: "Online"
payload_not_available: "Offline"
- platform: mqtt
name: "s31 Energy Yesterday"
state_topic: "tele/s31/SENSOR"
value_template: "{{ value_json['ENERGY'].Yesterday }}"
unit_of_measurement: "kWh"
availability_topic: "tele/s31/LWT"
qos: 1
payload_available: "Online"
payload_not_available: "Offline"
- platform: mqtt
name: "s31 Energy Total"
state_topic: "tele/s31/SENSOR"
value_template: "{{ value_json['ENERGY'].Total }}"
unit_of_measurement: "kWh"
availability_topic: "tele/s31/LWT"
qos: 1
payload_available: "Online"
payload_not_available: "Offline"
When MQTT broker or Home Assistant is restarted, or there is a WiFi outage, Tasmota device state may not be synced with Home Assistant. Use this automation to get all your (auto discovered) devices in sync, including power state, immediately after Home Assistant is started.
For autodiscovered devices:
automation:
- alias: "Sync Tasmota states on start-up - autodiscovery"
initial_state: true
trigger:
platform: homeassistant
event: start
action:
- service: mqtt.publish
data:
topic: "tasmotas/cmnd/state"
payload: ""
For manually configured devices:
automation:
- alias: "Sync Tasmota states on start-up - manual configuration"
initial_state: true
trigger:
platform: homeassistant
event: start
action:
- service: mqtt.publish
data:
topic: "cmnd/tasmotas/state"
payload: ""
automation:
- id: 'tasmota_firmware_installed'
alias: "Tasmota Firmware Installed"
initial_state: true
trigger:
- event: start
platform: homeassistant
action:
- data:
payload: '2'
topic: tasmotas/cmnd/status
service: mqtt.publish
initial_state: 'true'
Then you can make a sensor that detects the latest version of Tasmota and alerts you if there is an update. Autodiscovery only.
configuration.yaml
# Getting Firmware from JSON for Tasmota
sensor:
- platform: rest
resource: https://api.github.com/repos/arendst/Tasmota/releases/latest
name: Sonoff Firmware Version Available
username: !secret githubuser
password: !secret githubpass
authentication: basic
value_template: '{{ value_json.tag_name }}'
headers:
Accept: application/vnd.github.v3+json
Content-Type: application/json
User-Agent: Home Assistant REST sensor
- platform: mqtt
name: "Coffee Maker Firmware"
state_topic: "coffee/stat/STATUS2"
value_template: 'v{{ value_json.StatusFWR.Version }}'
- platform: mqtt
name: "Garage Door Firmware"
state_topic: "garage/stat/STATUS2"
value_template: 'v{{ value_json.StatusFWR.Version }}'
binary_sensor:
- platform: template
sensors:
sonoff_update_available:
value_template: >-
{{ (states.sensor.tasmota_firmware_version_available.state > states.sensor.coffee_maker_firmware.state) or (states.sensor.tasmota_firmware_version_available.state > states.sensor.garage_door_firmware.state)
}}
Note the above is for 2 switches.
customize.yaml
binary_sensor.tasmota_update_available:
friendly_name: Update Available Tasmota
device_class: problem
Then it will show as an alert icon that you can show in Lovelace.
Add a sensor like below for each Tasmota device whose firmware version you want to track.
# Example configuration.yaml entry
sensor:
- platform: mqtt
name: "Tasmota"
state_topic: "stat/tasmota/STATUS2"
value_template: "{{value_json['StatusFWR'].Version }}"
availability_topic: "tele/tasmota/LWT"
payload_available: "Online"
payload_not_available: "Offline"
qos: 0
Automation to have each device report firmware version on Home Assistant reboot. You can manually trigger this automation from Home Assistant UI.
automation:
- alias: "Tasmota Firmware Version Check"
trigger:
platform: homeassistant
event: start
action:
- service: mqtt.publish
data:
topic: "cmnd/tasmotas/STATUS"
payload: "2"
Here is some code that will display the IP address of yout newly flashed device.
The script:
script:
get_tasmota_ip:
alias: Get Tasmota New IP (tasmota)
sequence:
- data:
topic: cmnd/tasmota/ipaddress
service: mqtt.publish
The sensor:
sensor:
- platform: mqtt
name: "Tasmota IP"
state_topic: 'stat/tasmota/RESULT'
value_template: "{{ value_json.IPAddress1.split(' ')[1].replace('(','').replace(')','') }}"
Restart HA and plug in your newly flashed device. Click EXECUTE
(in the new group) and the "Tasmota IP" sensor will display the IP address. After finding out the new IP don't forget to change the topic of the new device to a unique one.
Tip
If you want all your devices to switch to autodiscovery method go through Developer tools - MQTT by publishing to grouptopic cmnd/tasmotas/SetOption19
with payload 1