Hisense TV Control

I found the same thing, you cant predict when the internal broker or WOL will sleep and stop responding. so that is why I’ve stuck with using an IR command for power on.
We don’t have discrete power on and power off commands so the MQTT broker on the TV is used to detect the state so everything stays in sync, so if I turn the TV off with its remote the HA dashboard updates with the correct state.

Is this a Hisense TV with android, or without?
I have ping sensor working properly with my 2 Hisense U6G Android TVs

For android-tvs, you want to turn on developer mode and there is also another setting that needs to be on (i forget off of top of my head but it is in the network settings).

If android TV then the writeup I created at Hisense U6G (and possibly other) Android TV Control - #8 by JasonLee still does work.
I do need to make one revision though as HA made mqtt sensors separate from other sensors.

If the TV is an Android model then you can hit me up with any other questions (preferably in the Android TV specific thread I created).

Writer of the thread you found at Hisense U6G (and possibly other) Android TV Control - #8 by JasonLee

Did you get all the MQTT control working?

Yes, sort of. Using your (OPTIONAL) code, I’ve got a switch that turns the TV off with the KEY_POWER payload. It’s not working fully as it doesn’t seem to know the TV is turned on and I have to catch the time when it is showing as on to turn it off. And I have to wait around 4 minutes after turning the TV off before it will respond to the magic packet and turn on again. I guess that’s a TV issue though.
I’m going to try more over the next few days when I get time.
Thanks for your post explaining how you got it working.
Edit: Just added a few scripts (TV, HDMI2 and HOME). The KEY_Home worked as you gave it but the TV and HDMI2 sources had to be amended as per a few differences I spotted using MQTT Explorer and RemoteNow.

Cant remember now if HA changed anything in regards to the switch from the (OPTIONAL) section. Here is my current config with mac redacted to YOURMAC

switch:
  - platform: template
    switches:
      mbr_hisense_tv:
        icon_template: >
          {% if is_state('switch.mbr_hisense_tv','on') %}
            {{ 'mdi:television-classic' }}
          {% else %}
            {{ 'mdi:television-classic-off' }}
          {% endif %}
        friendly_name: 'MBR Hisense TV'
        turn_on:
          service: wake_on_lan.send_magic_packet
          data:
            mac: 'YOURMAC'
        turn_off:
          service: mqtt.publish
          data:
            topic: '/remoteapp/tv/remote_service/YOURMAC$normal/actions/sendkey'
            payload: 'KEY_POWER'

I also have a binary sensor to ping the TV (set to 30 second interval), then I have an automation that Trigger - ping sensor state switches to on, Condition - switch = off, Action - set switch to on. Then the reverse for off.

If ping is not working, I would first test to see if pinging from a PC works as intended. If not then the issue in the TV. As stated, there is some setting in android that has to be set to be on for ping to work reliably.

I cant remember what it was that I did, but I did mess up when I was initially configuring and caused an MQTT loop that was DoS’ing the TV

Is there a way to change channel (ie, to 101) with just 1 publish instead of a series of key numbers?

I’m sure I saw something in the early days researching this subject but can’t find it now.

Edit:-
I found it using the RemoteNow app and setting up favourites. Then watching what was going on with MQTT Explorer on my PC.

The script Action for me is…

service: mqtt.publish
data:
  topic: /remoteapp/tv/ui_service/XX:XX:XX:XX:XX:XX$normal/actions/changechannel
  qos: 0
  retain: false
  payload: >-
    {"channel_param":"103#chc6de7882-fff4-4348-a981-5b9adc8bddfa#sldecc7100-1391-4f18-a5b2-dd39a6465504#4"}

No idea why that long string of characters is needed but I just copied it out of MQTT Explorer.

Edit 2:-
Well that worked for a couple of weeks until my telly had a software upgrade
(21 Feb 23). My changechannel scripts don’t work anymore and neither do the favourites in RemoteNow. The individual key press scripts still work though!

Hello, my bedroom TV works once. Is it possible to access a second Hisense TV with a bridge?
Sorry for my English is from Google Translater

Ok, took me 2 days, but finally I got it working for 55E78Q:

  1. Get cert and private key files from the zip file: GitHub - d3nd3/Hisense-mqtt-keyfiles: Some version of mqtt hisense require keys

  2. Get CA cert from your TV with open ssl command: openssl s_client -host 192.168.178.17 -port 36669 -prexit -showcerts
    Just copy both certs into a single file, just one after the other together with the header and end lines:

-----BEGIN CERTIFICATE-----
<...>
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
<...>
-----END CERTIFICATE-----
  1. Install MQTT Addon (mosquitto) integration, make sure to enable “custom configs”:
active: true
folder: mosquitto
  1. Add custom config to mosquitto, this means, adding hisense.conf to folder /share/mosquitto
connection hisense
address 192.168.178.17:36669
username hisenseservice
password multimqttservice
clientid HomeAssistant
bridge_insecure true
bridge_tls_version tlsv1.2
try_private false
start_type automatic
topic /remoteapp/# both 0 hisense ""
bridge_cafile /ssl/hisense_ca.crt
bridge_certfile /ssl/hisense_client.cer
bridge_keyfile /ssl/hisense_privkey.pem

Check protocol of mosquitto for errors when reading the config file. There has to be a line, that your config file was loaded:

Loading config file /share/mosquitto/hisense.conf
  1. Install this custom hisense integration: GitHub - sehaas/ha_hisense_tv: Hisense TV integration for Home Assistant and try to install. I got a infinite loading screen a long time… Took me a bit of time to fix all errors. But ne sure, integration is working. The problem is on your side :wink:

  2. Solve stucked loading screen:

6.1. Stucking loading screen without pin on your TV:

  • Mosquitto config is wrong, check Addon logs, maybe cert files cannot be found

6.2. You get a pin on the screen but no enter screen appears:

  • Use chrome browser (this is really funny), It just did not work on firefox.

Good luck

4 Likes

Thanks @Kaiser these clear steps really helped me get my Hisense connected.

I’ll just note the differences I encountered given my Hisense is a 2019 vintage 39P4 which doesn’t secure its MQTT. So it was a matter of figuring out which bits of the process I could ignore. Using the same step numbers as @Kaiser

1 - No need for cert and private keys

2 - No need for CA cert

3 - I don’t use HA MQTT Addon but instead I run docker Mosquitto so added following line to mosquitto.conf

include_dir /mosquitto/custom_config/

4 - Create /mosquitto/custom_config folder and put hisense.conf there. Since my older Hisense TV doesn’t need certs and keys, omit the following lines from hisense.conf

bridge_cafile /ssl/hisense_ca.crt
bridge_certfile /ssl/hisense_client.cer
bridge_keyfile /ssl/hisense_privkey.pem

5 - Install custom hisense integration

6 - No pin on TV, integration just works

As a further point, wake on lan didn’t work for me. I instead used a Chromecast plugged into a HDMI input and wake the TV via HDMI-CEC triggered from Home Assistant Google Cast integration. Works great.

1 Like

Not sure if I’m completely missing something but is there a way to tell when the played media is paused (e.g. streaming media)? I’ve looked through all the MQTT topics I can find but come up blank and yhe media player entity for my hisense TV will show the input but doesn’t say when media is paused, nor could I find any useful states in developer tools.

I’m looking to activate certain scenes based on media state (e.g. bring lights up slightly when media is paused) but can’t see how to trigger it.

To be clear, I’m looking to activate scenes however content is paused (don’t want to control just from HA).

Been using this configuration for some time now, on 14 TV’s been working brilliantly until very recently, and so far, we have only had the issue come up with one client, Using the following command to pull the certs, this used to work

openssl s_client -host 192.168.205.50 -port 36669 -prexit -showcerts
                                                                                                                                                          
604047BAFFFF0000:error:80000071:system library:BIO_connect:Host is unreachable:crypto/bio/bio_sock2.c:114:calling connect()                                                                                                         
604047BAFFFF0000:error:10000067:BIO routines:BIO_connect:connect error:crypto/bio/bio_sock2.c:116:                                                                                                                                  
connect:errno=113                                                                                                                                                                                                                   
---                                                                                                                                                                                                                                 
no peer certificate available                                                                                                                                                                                                       
---                                                                                                                                                                                                                                 
No client certificate CA names sent                                                                                                                                                                                                 
---                                                                                                                                                                                                                                 
SSL handshake has read 0 bytes and written 0 bytes                                                                                                                                                                                  
Verification: OK                                                                                                                                                                                                                    
---                                                                                                                                                                                                                                 
New, (NONE), Cipher is (NONE)                                                                                                                                                                                                       
This TLS version forbids renegotiation.                                                                                                                                                                                             
No ALPN negotiated                                                                                                                                                                                                                  
Early data was not sent                                                                                                                                                                                                             
Verify return code: 0 (ok)

Anyone else see this same issue recently

I bought a 55U7KQ that came out this year. It looks like Hisense did adjust the MQTT again, I am getting “Connection refused: Identifier rejected” over MQTT Explorer as well as within the mqtt logs on my raspberry although I used my phone’s MAC address as the client ID. Also on this newer model I can not use the Remotenow app, only the VIDAA app. Can anyone confirm that Hisense changed the identifier for newer models or help me out why it won’t accept the id?

Hi, I’m not a home assistant user but I’m trying to get MQTT to work with my U8KQ. They’ve definitely changed how the connection works. I’ll just copy/paste my findings that I posted to GitHub here:

Having the same issue on a 55U8KQ. I’m pretty sure Hisense changed the way MQTT auth works with newer models (those supporting only the Vidaa App).

I think this might be beyond the scope of what @Krazy998 is doing here, but here’s what I could find so far:

  • When setting up and using the Vidaa App, I haven’t been able to capture any MQTT traffic whatsoever using Wireshark. In general, there seems to be no direct communication between the TV and the device, as far as I could tell. The only packets the TV sent were DLNA and MDNS discovery related. Pretty much the same goes for the phone (tried an Android and iPhone).
  • I’ve looked through the files the Android app creates (/root/data/datacom.universal.remote.multi) and have found the following:
    • There’s a preferences file containing some identifiers for the device (the phone)
    • There are two SQLite Databases: comm.db and mqttAndroidService.db, with the latter being empty in my case even after pairing and using the remote functionality.

comm.dbcontains a lot of information regarding the paired TV, with probably the most interesting table being deviceconnectbean. This table (in my case) contains the following data:

id accesstoken mac refreshtoken accesstoken_duration_day accesstoken_time refreshtoken_time refreshtoken_duration_day
1 _+pUZJFGxZtnQsDYQEc3ewOv4dG/xJuvlR93qp7CVC6+pX/xN571Bh79/s76QWgS9 e0d8c4d2280088b8632f70f6 #+pUZJFGxZtnQsDYQEc3ewOv4dG/xJuvlR93qp7CVC6+juMFCy+y8Sv9I2PvnUysQ 2 1697805808 1697805808 30

This seems to indicate that the authentication process is much more complex now and I have no idea where to start with this. Anyways, I’ll attach the database so you can have a look at them:
comm.db.zip

1 Like

Hi

I have a new 2023 model 100U7HQ, and I experience the same issue. Did any of you find a solution for this ?

Sounds like VIDAA 7 TVs have modified the way remote control works.

I have L9H laser tv running VIDAA 6. Everything works except the sensor shows the TV is always on which technically is correct, since it’s in standby of sorts. Is there a variable that can detect whether the TV is really on or not (short of using ESP, smart power plug readings etc.).

Well… seems my TV got the latest software update and without thinking I let it install.

Now the MQTT is locked down, seems to be a complex rolling code password now as far as anyone online can tell.

Hello, I am in the same situation. I am migrating from HA OS to homeassistant container.
I have moved my files to the routes you indicate and in the mosquitto log it appears: 1702136740: Connecting bridge hisense (192.168.1.20:36669)
When I try to add the integration in home assistant it keeps trying infinitely without any errors.
What do you mean: NVM solved it?

@NeeeeB Hello - I just want to say thank you sooooooo much for this step by step guide to epictechlab in post Hisense TV Control - #242 by NeeeeB. It worked for me!!

I can now control my hisense 65u8hqtuk via mqtt in home assistant. I’ve spent several long days trying to make this work and trying all sorts of configs. This worked great (so far!).

One tip for anyone reading. When using the GitHub integration within Home Assistant UI, I’d recommend loading Home Assistant into Incognito on Chrome, as once you’ve entered the pin it will integrated properly. When I did it via my normal chrome browser, I got the spinning wheel.

I had a similar issue after I entered the PIN and then it got stuck spinning. I just backed out and added the integration again with the exact same settings and it added correctly the second time, no PIN needed the second time.

This is working for me now however my TV is not showing off properly for some reason. It always shows as on (presumably because that MQTT server on the TV becomes inaccessible once the TV powers off, so I guess MQTT broker never sees the off command). This is made worse by the fact that any commands sent to the device in HA all set queued and then execute when the TV (and thus the MQTT broker) comes back online. If anyone knows how to fix this I would be very interested.

I also ran into a second issue when trying to add a second TV. MQTT add-on would no longer start and gave an error:

Error: Bridge local_clientid ‘local.HomeAssistant’ is not unique. Try changing or setting the local_clientid value for one of the bridges.

It wasn’t until I changed

clientid HomeAssistant

to

clientid HomeAssistantLivingRoomTV

in my second .conf file that MQTT add-on would start up normal again.

That was why I manually integrated the TV using some Nodered stuff, pinging the mqtt server to check that it is online and if not the next power on command would be sent via an IR emitter to wake the TV up, then the mqtt would come online and all commands would go through that.

That got around both the TV going to sleep an disconnecting, but also gave me a way to have separate on and off commands without discrete IR power commands