Home Assistant: Add a Custom IR Remote and Support Tmall Genie and Xiaodu
Preparation
- An online
Mi Home universal remotealready added toHome Assistant - The
IP addressandtokenof theMi Home universal remote
How do you get the
IP address? Open theMi Home appon your phone, select the device bound to your Xiaomi account, enter it, then tap the...in the top right ->More settings->Network informationto view the deviceIP address.
How do you get the
token? Reference 1: Use an open-source tool to export Xiaomi Token Reference 2: Retrieving the Access Token
Learn Custom Commands
- Open
Home Assistant->Developer Tools->Services, enterxiaomi_miio.remote_learn_commandinServices, then find the corresponding entity inEntity. For example, myentity_idisremote.mo_neng_yao_kong_sh. - Click
Call Service, then within 30 seconds point the remote at the Mi Home universal remote and press the button you want to learn. - If everything is correct, the system will receive a notification containing the
base64encoded infrared command.
Configure Custom Commands
- Open
Home Assistant->Supervisor->File editor->Open Web UI->/config/configuration.yaml - Under the existing
remotesection, addcommands. The full sample configuration is as follows:
remote:
- platform: xiaomi_miio
host: 192.168.1.86
token: 8ec29e26xxxxxxxxxfcxxxxd3c9ef9
model: chuangmi.remote.v2
name: 万能遥控 SH
slot: 1
timeout: 30
hidden: false
commands:
bladeless_fan_on_off:
command:
- raw:mMynEwlk0mEwlkxmU1AIKZABlMQDDmwCNANeAQUzAIOaAI2AQk3As8Bp5xMwGrAj8AQwhimc5AasGLwffAaIEfwa/BrUFlg1/Br8GtACPBr8Gvwa/AjwBpBXoCG8GLwofCY8GsgFSEo8UPxyvE68H3wmKCGsNdga4C88GJ4A
bladeless_fan_shake_head:
command:
- raw:mMynEwlkznMwlgBETSaAGHMwEaAa8AjwCPA+cDEpmByQCJziZgLIAiYKCAEMBZwNfgs+AR4H3g1+Ch4NfhQ2Cz4BDzUBHw1/Br8UPwa/Bi8Ajwa/Br8ZTwa/Fe8FnwCPEW8NfwUPBryAAA==
bladeless_fan_speed:
command:
- raw:mMymswlk0mUwlkxmU4AIKYABlMQDDmwCNANTMwDDmgBFAfQBrAEfgNLOJnNwLKA18BrAaymc5BH8GtQofAIUFkgEcBr8LzwhvBH8AgwofAI8Ol5xMwJyCzgDXwa/BQ8CPgGvBr8GtQUPGv8UOwR/A18a/BQ/GU8ZSwGngAA=
bladeless_fan_timer:
command:
- raw:mMymswlk0mUwlgBETSYAGHNwEaAamYgNMBHACMgEeARIHyTeazMFHwbPAa8Ej5ZNAQkmgDXg2eDZ4NngNeA1gNngx+A1kxmU4BsMBdACSmc5AIYE0wbPDZ8L7wCCmwBHgNYGzYNkBfeDZ4JHgtIGzoNngjsGzIKPi16AiUAA
bladeless_fan_wind_type:
command:
- raw:mMymswlk0mUwlgBETSYgGHNgEaAa8AjwLMAa8AhZxMAR0ANMFDwPmAagAhgR/AIKaAEGAIk4mEsmc5ARoAjJvOQGiAjgCzpmA14DWAEeBH4DSBH2DWwXkAWeDX4MXg1+BH4BFhr+AIQNfAIsAQoE5Aj+BZ4EfgEMM4U3nIDRARwBZIDRAfZAAA==
The sample configuration above adds 5 custom infrared commands.
Configure Command Scripts (turn commands into entities)
- Open
Home Assistant->Supervisor->File editor->Open Web UI->/config/scripts.yaml - Add the configuration below:
bladeless_fan_on_off:
alias: Toggle
sequence:
- service: remote.send_command
entity_id: 'remote.mo_neng_yao_kong_sh'
data:
command: 'bladeless_fan_on_off'
bladeless_fan_shake_head:
alias: Swing
sequence:
- service: remote.send_command
entity_id: 'remote.mo_neng_yao_kong_sh'
data:
command: 'bladeless_fan_shake_head'
bladeless_fan_speed:
alias: Speed
sequence:
- service: remote.send_command
entity_id: 'remote.mo_neng_yao_kong_sh'
data:
command: 'bladeless_fan_speed'
bladeless_fan_wind_type:
alias: Wind Mode
sequence:
- service: remote.send_command
entity_id: 'remote.mo_neng_yao_kong_sh'
data:
command: 'bladeless_fan_wind_type'
Add HAVCS Devices
After turning commands into entities, adding devices becomes very easy.
- Open
Home Assistant->HAVCS Devices->+ - Fill in the fields as required and click
Add - After all
HAVCSdevices have been added, clickRefresh