I spent longer than I’d like to admit integrating this AC with HA. But the end result is spot on. I assume the mapping I obtained will be the same for you. If not, here’s my approach so you can perform the same if needed.
- On the Tasmota Console run weblog 4. This provides debug info to the console.
- I played around with the settings on the AC and observed the messages back (Tasmota debug).
- From there I determined what responses I needed to send back to HA for status updates. Unfortunately these DpId formats didn’t match the syntax described on the blakadder site.
- I wrote a catchall Tasmota rule that will send the MQTT messages out with the relevant data (Tasmota Rule1). It sends as stat/topic/DpId with hex formatted value (0x…). I deal with the mapping of these on the HA side.
- With that same info I determined what tuyasend<x> commands could be used to control the unit.
- Getting HA to send the relevant commands over MQTT proved difficult. I could only get Tasmota to listen to MQTT Events, and I couldn’t find how to manipulate HAs MQTT climate integrations outbound data. Fortunately all message data proved unique, so I squeezed in the mapping for all possible combinations (Tasmota Rule2 and Rule3)
- I included the serialsend5 command as per the blakadder details. That forces all values to be queried and sent back to HA via Rule1. I also listen to an MQTT refresh event on the AC which I can trigger from HA if needed to update status. I have a HA startup automation that fires this.
- The HA MQTT climate setup is pretty self-explanatory. My unit is named ac1 in the below. State topics are mapped to the DpId. The temperature values required hex to decimal conversion, and the other values are just straight templates.
- Only shortcoming here is that the mode of the unit always reports cool, fan_only, dry or heat. It won’t report off. For this reason I have commented out the mode_state_topic. Given control is typically via HA anyway, this isn’t proving a bother to me.
- Put weblog back to 2 on Tasmota when you’re done, weblog 2
Tasmota Rules
Rule1
on TuyaReceived#DpId do var1 %value% endon
on TuyaReceived#DpIdData do publish stat/%topic%/%var1% 0x%value% endon
on event#refresh do serialsend5 55aa0001000000 endon
on power1#state=1 do serialsend5 55aa0001000000 endon
on mqtt#connected do serialsend5 55aa0001000000 endon
Rule2
on event#low do tuyasend4 5,0 endon
on event#medium do tuyasend4 5,1 endon
on event#high do tuyasend4 5,2 endon
on event#off do tuyasend 104,0 endon
on event#on do tuyasend 104,1 endon
on event#cool do tuyasend4 4,0 endon
on event#fan_only do tuyasend4 4,1 endon
on event#dry do tuyasend4 4,2 endon
on event#heat do tuyasend4 4,3 endon
on event#16.0 do tuyasend2 2,16 endon
on event#17.0 do tuyasend2 2,17 endon
on event#18.0 do tuyasend2 2,18 endon
on event#19.0 do tuyasend2 2,19 endon
Rule3
on event#20.0 do tuyasend2 2,20 endon
on event#21.0 do tuyasend2 2,21 endon
on event#22.0 do tuyasend2 2,22 endon
on event#23.0 do tuyasend2 2,23 endon
on event#24.0 do tuyasend2 2,24 endon
on event#25.0 do tuyasend2 2,25 endon
on event#26.0 do tuyasend2 2,26 endon
on event#27.0 do tuyasend2 2,27 endon
on event#28.0 do tuyasend2 2,28 endon
on event#29.0 do tuyasend2 2,29 endon
on event#30.0 do tuyasend2 2,30 endon
# Enable the rules
Rule1 1
Rule2 1
Rule3 1
HA Template
climate:
- platform: mqtt
name: Study Airconditioner
min_temp: 16
max_temp: 30
modes:
- "off"
- "cool"
- "fan_only"
- "dry"
- "heat"
swing_modes:
- "off"
- "on"
fan_modes:
- "low"
- "medium"
- "high"
power_command_topic: "cmnd/ac1/POWER"
mode_command_topic: "cmnd/ac1/event"
# mode_state_topic: "stat/ac1/4"
# mode_state_template: "{% if value=='0x00' %}cool{% elif value=='0x01' %}fan_only{% elif value=='0x02' %}dry{% elif value=='0x03' %}heat{% endif %}"
fan_mode_command_topic: "cmnd/ac1/event"
fan_mode_state_topic: "stat/ac1/5"
fan_mode_state_template: "{% if value=='0x00' %}low{% elif value=='0x01' %}medium{% elif value=='0x02' %}high{% endif %}"
swing_mode_command_topic: "cmnd/ac1/event"
swing_mode_state_topic: "stat/ac1/104"
swing_mode_state_template: "{% if value=='0x00' %}off{% elif value=='0x01' %}on{% endif %}"
temperature_command_topic: "cmnd/ac1/event"
temperature_state_topic: "stat/ac1/2"
temperature_state_template: "{{ value | int(base=16) }}"
current_temperature_topic: "stat/ac1/3"
current_temperature_template: "{{ value | int(base=16) }}"
HA Automation
alias: MQTT - Update state on start
trigger:
- event: start
platform: homeassistant
action:
- service: mqtt.publish
data:
payload: refresh
topic: cmnd/ac1/event
Tasmota debug
#power
03:58:37 {"TuyaReceived":{"Data":"55AA03070005010100010011","Cmnd":7,"CmndData":"0101000100","DpId":1,"DpIdType":1,"DpIdData":"00"}}
#current temp
04:17:06 {"TuyaReceived":{"Data":"55AA03070008030200040000001731","Cmnd":7,"CmndData":"0302000400000017","DpId":3,"DpIdType":2,"DpIdData":"00000017"}}
#set temp
04:07:31 {"TuyaReceived":{"Data":"55AA0307000802020004000000152E","Cmnd":7,"CmndData":"0202000400000015","DpId":2,"DpIdType":2,"DpIdData":"00000015"}}
#swing
off: 06:02:46 {"TuyaReceived":{"Data":"55AA03070005680100010078","Cmnd":7,"CmndData":"6801000100","DpId":104,"DpIdType":1,"DpIdData":"00"}}
on: 06:02:15 {"TuyaReceived":{"Data":"55AA03070005680100010179","Cmnd":7,"CmndData":"6801000101","DpId":104,"DpIdType":1,"DpIdData":"01"}}
#fan
low: 06:07:28 {"TuyaReceived":{"Data":"55AA03070005050400010018","Cmnd":7,"CmndData":"0504000100","DpId":5,"DpIdType":4,"DpIdData":"00"}}
medium: 06:06:37 {"TuyaReceived":{"Data":"55AA03070005050400010119","Cmnd":7,"CmndData":"0504000101","DpId":5,"DpIdType":4,"DpIdData":"01"}}
high: 06:07:11 {"TuyaReceived":{"Data":"55AA0307000505040001021A","Cmnd":7,"CmndData":"0504000102","DpId":5,"DpIdType":4,"DpIdData":"02"}}
#mode
cool: 06:04:44 {"TuyaReceived":{"Data":"55AA03070005040400010017","Cmnd":7,"CmndData":"0404000100","DpId":4,"DpIdType":4,"DpIdData":"00"}}
fan: 06:03:43 {"TuyaReceived":{"Data":"55AA03070005040400010118","Cmnd":7,"CmndData":"0404000101","DpId":4,"DpIdType":4,"DpIdData":"01"}}
dry: 06:04:07 {"TuyaReceived":{"Data":"55AA03070005040400010219","Cmnd":7,"CmndData":"0404000102","DpId":4,"DpIdType":4,"DpIdData":"02"}}
heat: 06:04:25 {"TuyaReceived":{"Data":"55AA0307000504040001031A","Cmnd":7,"CmndData":"0404000103","DpId":4,"DpIdType":4,"DpIdData":"03"}}