OP contains instructions for IR devices via Google SDK.
For RF Fans/devices via Scenes (no Google SDK), check first comment!
Disclaimer: this is a multi-cloud workaround including Tuya and Google Assistant. Don’t proceed if you only want local control, unless you can share a better way!
It is frustrating that despite having 3 Tuya integrations (Official, localtuya, tuya-local), none support IR remotes and sub-devices.
Unlike Broadlink remotes, Tuya remotes don’t allow any kind of local/manual control, nor via API (that I know, happy know if possible!)
I had one Tuya IR remote, and a Broadlink RM3 Mini. I have 2 ACs, but I also have 2 ceiling fans that are RF. So, I bought a Tuya IR + RF remote to replace the Broadlink. I wanted to control the ACs from HA like a thermostat.
So… sharing what I did for IR AC:
How to control a Tuya IR AC from HA as a thermostat:
Seems like a lot, but don’t be scared
Requisites:
- A Tuya IR remote with the AC already learnt
- Google Assistant with Tuya connected to it
- Official Tuya Cloud integration set up and working - sorry, no local control for this…
- Google Assistant SDK set up
- SmartIR integration - this allows to have the AC / Climate in HA with all the right modes for your AC. Generic Thermostat is not enough.
- Automation - covered below
Step 0: Requisites
Make sure you have the requirements 1-5 above installed and set up.
You might need some time if you didn’t already have it. In my case, I already had all from before…
Step 1: Smart IR
- Follow the instructions in the SmartIR Climate section to set it up
You should end up with something like this in your condiguration.yaml:
smartir:
climate:
- platform: smartir
name: AC Comedor
unique_id: ac_comedor
device_code: 1070
controller_data: home-assistant/ac-comedor/command
# controller_data: remote.broadlink_rm_mini_3_remote
temperature_sensor: sensor.home_temperature
humidity_sensor: sensor.home_humidity
- platform: smartir
name: AC Habitacion
unique_id: ac_habitacion
device_code: 1070
controller_data: home-assistant/ac-habitacion/command
temperature_sensor: sensor.sensor_habitacion_temperature
humidity_sensor: sensor.sensor_habitacion_humidity
Note: I have 2 in the example, which are actually controlled by the 2 different Tuya IR remotes. Plus, I have temp sensors in each room where the ACs are
Important: device_code depends on your AC, and it’s relevant because it defines the modes, temperatures, etc for your AC. Spend some time in the SmartIR Climate devices to find your model or the one that is similar to yours (open the files).
controller_data is just fake. Just use what I have (adapt the ac-xxx name).
- Restart HA so that these entities.
- You will now have new climate entities in HA.
Step 2: Prepare the AC in Google Home app
In the Google Home app, you probably see something like this for your Tuya AC device, a very limited, half-broken device that only allows On & Off, no temperature.
Good news: it’s only the UI - you can control it via voice, which is the base of this workaround, as you’ll see in Step 3.
- Rename that device to something “internal” and one-wordy, like ACLVR (standing for AC Living Room).
Step 3: The automation that makes
We need to make the HA climate trigger the changes to Google Assistant, so that Google Assistant makes the work with Tuya.
We will use the Google Assistant SDK to ask google to set the AC to the desired mode/temp/speed when we change it in the HA climate entity.
So, this is my automation:
alias: Aire Comedor (Tuya Google SDK)
description: ""
trigger:
- platform: state
entity_id:
- climate.ac_comedor
id: power
from: null
to: null
- platform: state
entity_id:
- climate.ac_comedor
id: temperature
attribute: temperature
for:
hours: 0
minutes: 0
seconds: 0
- platform: state
entity_id:
- climate.ac_comedor
id: fan speed
attribute: fan_mode
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- power
sequence:
- if:
- condition: state
entity_id: climate.ac_comedor
state: "off"
alias: If Mode is Off
then:
- service: google_assistant_sdk.send_text_command
data:
command: turn ACLVR off
alias: Google to turn OFF
else:
- service: google_assistant_sdk.send_text_command
data:
command: turn ACLVR on
alias: Google to turn ON
enabled: true
- service: google_assistant_sdk.send_text_command
data:
command: >-
set ACLVR to
{{states('climate.ac_comedor')|replace("fan_only", "fan
only") }}
alias: Google to set mode
- service: google_assistant_sdk.send_text_command
data:
command: >-
set temperature ACLVR to
{{state_attr('climate.ac_comedor','temperature')|round()}}
degrees
alias: Google to set temperature
- service: google_assistant_sdk.send_text_command
data:
command: >-
set ACLVR speed to
{{state_attr('climate.ac_comedor','fan_mode')}}
alias: Google to set fan speed
alias: On or Off
- conditions:
- condition: trigger
id:
- temperature
sequence:
- service: google_assistant_sdk.send_text_command
data:
command: >-
set ACLVR temperature to
{{state_attr('climate.ac_comedor','temperature')|round()}}
alias: Google to set temperature
- conditions:
- condition: trigger
id:
- fan speed
sequence:
- service: google_assistant_sdk.send_text_command
data:
command: >-
set ACLVR speed to
{{state_attr('climate.ac_comedor','fan_mode')}}
alias: Google to set fan speed
mode: single
When turning on, it sends all the commands (on, mode, temp, speed) one after the other. When changing temperature or fan mode/speed, it only sends that.
OPTIONAL - Step 4: Have the full AC control back in Google Home / Google Assistant
If you want to have the full AC control in the GA/GH app, you can expose the HA climate back to Google (which sends a command to Google, which controls Tuya IR AC), to have what we should get from Tuya directly in GA and HA… So, full circle
If you weren’t already exposing the climate entities in your google-assistant entry in configuration.yaml, do it. Mine looks like this (you should already have most of this from requisite 4!), but read the documentation to adjust it to your needs (like expose_by_default: true instead of exposed_domains, etc.)
google_assistant:
project_id: home-assistant
service_account: !include SERVICE_ACCOUNT.JSON
report_state: true
exposed_domains:
- light
- input_boolean
- climate
That should be it! Hopefully I haven’t forgotten anything, so let me know if you have issues or questions and I’ll review.
See next comment for Fans / RF devices.