EDITED 01/25/2023 DUE TO CHANGE IN WAY HOME ASSISTANT DOES MQTT SENSORS
Hey all, I wanted to share my working configuration for Hisense MQTT control with a 2021 U6G Android TV. As of early 2023 this communication method works for all Android OS Hisense TVs, here is the discrepences reported from other users:
For A7HQ TVs, see this MQTT topic found by Wingnut: Hisense U6G (and possibly other) Android TV Control - #36 by Wingnut ***
For U8G TVs, see this MQTT topic by JasonLee Hisense U6G (and possibly other) Android TV Control - #23 by JasonLee
I want to give credit to ReDaLeRt whoâs write up at https://github.com/tiagofreire-pt/Home_Assistant_Hisense_TV got me most of the way, 95% of this is their work, with me figuring out the 5% that has changed.
This was done on a Hisense U6G TV, Home Assistant version is core-2021.10.6 with Mosquito Brooker add-on, this has been updated and is working on 20221213.1
Prerequisites:
-
You will need to download the app RemoteNow to your Android phone, I do not know if there is an iOS app for this (or if it will work the same).
FYI, if available, use an older android device that pre-dates the revolving mac address feature (where your phone gives a new mac to the router each time you connect to wifi). On a Pixel 5 (running Android 12) set to send its real MAC to the router, this would not work; however using an older LG G7 (running Android 10) worked just fine. -
If not already configured, you will need the Mosquito Brooker and Samba addon installed to Home Assistant (under Supervisor).
-
Having Mosquito Explorer installed on a Windows PC will also help with troubleshooting.
Now that all of the pre stuff is out of the way:
-
Set a static IP for your TV either in the TV GUI or via static lease on your router.
Take note of both the IP and the MAC of the TV for the steps bellow. -
Open the RemoteNow app, find and connect to your TV and then input the pair code. Test that the remote can control the TV.
Now write down the MAC address of the phone/tablet you used to connect the RemoteNow app to the TV. This should be in WiFi settings, but may be different since every OEM tweaks things different.
The purpose of this is to authorize/authenticate the MAC of a device to control your TV, which we can now spoof in Home Assistant (or other MQTT brokers) -
On a PC, access your Home Assistant Samba share:
* Windows: \\YOUR_HA_LAN_IP\
* Linux: smb://YOUR_HA_LAN_IP/
-
Create a file called âhisense.confâ, and save it to â/share/mosquitto/â. Paste the code bellow into the file and only change the IP_OF_TV and the MAC_OF_REMOTENOW_ANDROID fields (MAC is in AA:BB:CC:DD:EE:FF format).
connection hisensemqtt
address IP_OF_TV:36669
username hisenseservice
password multimqttservice
clientid MAC_OF_REMOTENOW_ANDROID
bridge_cafile /ssl/hisense.crt
bridge_insecure true
bridge_tls_version tlsv1.2
try_private false
start_type automatic
topic +/remoteapp/# both
- In Home Assistant, go to Supervisor, and then Mosquitto Brooker, then configuration tab, make sure your config matches the following (username and password is redacted):
logins:
- username: ********
password: ********
customize:
active: true
folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false
anonymous: false
retain: true
- Now from a terminal of a linux system run the following command (inputting your TV IP address):
openssl s_client -host TV_IP_ADDRESS -port 36669 -showcerts
-
Paste the output into a notepad.
-
Create a new file called âhisense.crtâ and copy ONLY the two certs in the previous step, now save it to /ssl/ folder of Home Assistant Samba share. The file should like like this:
-----BEGIN CERTIFICATE-----
(THE KEY DATA)
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
(THE KEY DATA)
-----END CERTIFICATE-----
- Create an entry for your TV in the âknown_devices.yamlâ file in â/config/KD/â (input the MAC of your TV).
hisense_tv:
icon: 'mdi:television-classic'
mac: TV_MAC_ADDRESS
name: 'Hisense TV'
picture:
track: true
- Now we will edit the âconfiguration.yamlâ file (in â/config/â folder). Copy the following code into the file.
wake_on_lan:
mqtt:
sensor:
- name: "TV - Source"
state_topic: "/remoteapp/mobile/broadcast/ui_service/state"
value_template: "{{ value_json.sourceid }}"
- name: "TV - VOL"
state_topic: "/remoteapp/mobile/broadcast/platform_service/actions/volumechange"
value_template: "{{ value_json.volume_value }}"
(OPTIONAL) You can use this to create an on-off switch in Home Assistant.
You will need to input the MAC of your TV for the WOL portion to turn TV on(do not remote the â 's), and the MAC of the android you used RemoteNow for the MQTT payload string to turn the TV Off.
switch:
- platform: template
switches:
hisense_tv:
icon_template: >
{% if is_state('switch.hisense_tv','on') %}
{{ 'mdi:television-classic' }}
{% else %}
{{ 'mdi:television-classic-off' }}
{% endif %}
friendly_name: 'Hisense TV'
value_template: >
{{ is_state('device_tracker.hisense_tv', 'home') }}
turn_on:
service: wake_on_lan.send_magic_packet
data:
mac: 'MAC_OF_TV'
turn_off:
service: mqtt.publish
data:
topic: '/remoteapp/tv/remote_service/REMOTENOW_MAC$normal/actions/sendkey'
payload: 'KEY_POWER'
- Here is some common commands you can send via scripts or buttons or REST API calls. The example is from my scripts.yaml file
You need to change the REMOTENOW_MAC to the MAC address of the Android device you connected to the TV via RemoteNow.
hisense_input_tv:
alias: TV - Input TV
sequence:
- service: mqtt.publish
data:
topic: /remoteapp/tv/ui_service/REMOTENOW_MAC$normal/actions/changesource
payload: '{"displayname":"Channels","hotel_mode":"","httpIcon":"","isDemo":false,"is_lock":"","is_signal":"","sourceid":"1","sourcename":"Tuner"}
platform_service'
mode: single
hisense_input_hdmi_1:
alias: TV - Input HDMI 1
sequence:
- service: mqtt.publish
data:
topic: /remoteapp/tv/ui_service/REMOTENOW_MAC$normal/actions/changesource
payload: '{"displayname":"HDMI 1","hotel_mode":"","httpIcon":"","isDemo":false,"is_lock":"","is_signal":"","sourceid":"2","sourcename":"HDMI
1"}'
mode: single
hisense_input_hdmi_2:
alias: TV - Input HDMI 2
sequence:
- service: mqtt.publish
data:
topic: /remoteapp/tv/ui_service/REMOTENOW_MAC$normal/actions/changesource
payload: '{"displayname":"HDMI 2","hotel_mode":"","httpIcon":"","isDemo":false,"is_lock":"","is_signal":"","sourceid":"3","sourcename":"HDMI
2"}'
mode: single
hisense_input_hdmi_3:
alias: TV - Input HDMI 3
sequence:
- service: mqtt.publish
data:
topic: /remoteapp/tv/ui_service/REMOTENOW_MAC$normal/actions/changesource
payload: '{"displayname":"HDMI 3","hotel_mode":"","httpIcon":"","isDemo":false,"is_lock":"","is_signal":"","sourceid":"4","sourcename":"HDMI
3"}'
mode: single
hisense_mute:
sequence:
- service: mqtt.publish
data:
topic: /remoteapp/tv/remote_service/REMOTENOW_MAC$normal/actions/sendkey
payload: KEY_MUTE
mode: single
alias: TV - Mute
hisense_volume_up:
alias: TV - Volume up
sequence:
- service: mqtt.publish
data:
topic: /remoteapp/tv/remote_service/REMOTENOW_MAC$normal/actions/sendkey
payload: KEY_VOLUME_UP
mode: single
hisense_volume_down:
alias: TV - Volume down
sequence:
- service: mqtt.publish
data:
topic: /remoteapp/tv/remote_service/REMOTENOW_MAC$normal/actions/sendkey
payload: KEY_VOLUME_DOWN
hisense_channel_up:
alias: TV - Channel up
sequence:
- service: mqtt.publish
data:
topic: /remoteapp/tv/remote_service/REMOTENOW_MAC$normal/actions/sendkey
payload: KEY_CHANNELUP
hisense_channel_down:
alias: TV - Channel down
sequence:
- service: mqtt.publish
data:
topic: /remoteapp/tv/remote_service/REMOTENOW_MAC$normal/actions/sendkey
payload: KEY_CHANNELDOWN
hisense_home:
alias: TV - Home
sequence:
- service: mqtt.publish
data:
topic: /remoteapp/tv/remote_service/REMOTENOW_MAC$normal/actions/sendkey
payload: KEY_HOME
Using MQTT broker and the RemoteNow app, you should be able to see the MQTT topic for streaming app inputs and any other buttons I did not list
You can also check out ReDaLeRtâs lovelace setup in the github link above.
I have my own custom-made solution for TV remote control so I did not get too deep into setting up lovelace cards for this aspect, hence why I did not include any lovelace configuration in my writeup.