Fixing my stupid TCL TV using Harmony and Home Assistant

Nov 6, 2026

In 2026, we bought a 65-inch TCL MQLED80K here in Sweden. We were looking for an upgrade, got a great deal on the TV, and were impressed by the quality of the screen.

This is a TV, so it should be pretty basic to install, right? Wrong! This became another home automation project because I expected to be able to turn a modern smart TV on and off reliably. Unreasonable expectations, I know.

We already use a Logitech Harmony Elite remote. This makes sure all our devices (Denon receiver, set-top box, Chromecast, and TV) turn on and off correctly and set the correct inputs without having to juggle three different remotes. It's such a shame that Logitech discontinued the Harmony series since the actual remote hardware still works so well and has a premium feel in the hand. We use the Harmony every day and have done so for almost a decade now, and it's easy for everyone in the household to use.

Unfortunately, the TCL TV lacks usable discrete infrared commands for Power On and Power Off. The commands available for our TV only provide a power toggle. This is frustrating because our old, entry-level Samsung TV has one IR command for on and one IR command for off, which ensures Harmony and the TV stay in sync. When you turn on the TV with Harmony, it sends the On command. When you turn it off, it sends the Off command. Instead, the TCL only supports "Toggle power", and if Harmony ever gets out of sync, everything stops working without an easy way to fix it.

Imagine I'm away from home and someone accidentally turns the TV on without using Harmony, or an IR pulse gets lost thanks to direct sunlight falling on the TV. Then, if they try to watch TV, chaos breaks loose. Turning the TV on with the Harmony remote turns on the sound system so the TV audio starts playing, but the TV turns off. Turning the TV off again turns on the TV but turns the audio off.

Solving this issue led me down an interesting rabbit hole, and I learned many things I want to share in this blog post. I hope you enjoy it.

Setting up Harmony

The first layer of resilience is configured within Harmony itself. We want the TV to turn on, then switch to HDMI 1. Since we are using a Denon receiver to do all the HDMI switching, the TV should always be forced to this input. The TCL sometimes wants to show its smart TV home screen, but we always want it to show HDMI 1.

The problem, however, is that the Harmony IR codes for the MQLED80K don't include direct input commands. Don't get me wrong, I am still grateful that Logitech keeps maintaining the database years after shutting down the product line and that there is an entry for the MQLED80K. However, the entry for this TV is very poor, and we need to work around it.

After some research, I found that you can enter a different model number in Harmony that has the same codes as my TV but also adds input switching and number-pad commands. Configure it as:

  • Manufacturer: TCL
  • Model: 75C835

The power-on button is zero

Next, I sat down and tried every button on the TCL remote and found something interesting. Sending the number 0 turns the TV on and does not turn it off. This makes it perfect for forcing the correct power state.

In Harmony's device power setup, configure separate commands for on and off, and use:

  • Power On: the number-pad command for 0.
  • Power Off: Power Toggle.

The state can still drift when turning the TV off, but it is now quickly fixed by turning it on and then off again.

Then set up Harmony to send HDMI 1 as the input selector in the startup sequence. In my testing, this brought the TV back to HDMI 1 from the Android home screen and settings menus.

Adding ADB

The above setup works and has been pretty reliable, but I wanted to take it a step further. Having heard of Android Debug Bridge (ADB) commands for Android-based TVs, I wanted to see what they could do. I connected my TV to my home network with an Ethernet cable (much better than Wi-Fi) and started tinkering. To enable ADB, follow these steps:

  1. Add the TV as a static DHCP mapping in pfSense so it always gets the same IP address.
  2. Open Settings → System → About and find Android TV OS build. Click it seven times, until the TV tells you that developer options are enabled.
  3. Return to System, open Developer options, and enable ADB debugging. Depending on the firmware, the option may be called USB debugging, ADB debugging, or Network debugging. Enable network debugging too if it is a separate setting. The menu names can vary; the aim is to allow ADB connections over the home network.

Then, on my Linux server, I installed ADB:

sudo apt install adb

With the TV awake, connect to its reserved IP address:

adb connect 192.0.2.50:5555

Replace 192.0.2.50 with your TV's address. Watch the TV for the debugging authorization prompt, approve the Linux computer, and select Always allow from this computer. Then check the connection and run a small command:

adb devices
adb -s 192.0.2.50:5555 shell echo ready

The TV should appear with the status device, and the second command should print ready. If it says unauthorized, check the TV for the approval dialog and reconnect after accepting it.

With ADB connected, let's see what this TV can do. My agent was able to figure out the wake or sleep events from the standard Android key codes:

# Turn the TV on
adb shell input keyevent 224

# Turn the TV off
adb shell input keyevent 223

Unlike a power toggle, these events are discrete. However, when the TV is off, it no longer responds to ADB, and the On command therefore stops working. After unsuccessfully messing with the power-saving settings on the TV, I had to settle on using Wake-on-LAN. At least on Ethernet, the network interface responds to the magic packet and turns the system on.

I installed the utility on the server:

sudo apt install wakeonlan

Then I looked up the MAC address and ran this command with the TV off:

wakeonlan 02:00:00:00:00:50

As if by magic, it turned on!

I could then run ADB commands like these:

adb connect 192.0.2.50:5555
adb -s 192.0.2.50:5555 shell echo ready

These let me check programmatically when the TV is ready and responding to commands.

Next, we found that the following command switches the input to HDMI 1:

adb shell am start -W -a android.intent.action.VIEW -d \
  "content://android.media.tv/passthrough/com.tcl.tvinput%2F.TvPassThroughService%2FHW15"

We found the input identifier by inspecting the TV's input map:

adb shell dumpsys tv_input

Our TV reports HDMI 1 as com.tcl.tvinput/.TvPassThroughService/HW15. The launch command encodes that identifier in an Android passthrough input URI. Check your own input map before copying it: HW15 is what our firmware reports, rather than a universal HDMI 1 identifier.

With all these commands at our disposal, we can begin automating with Home Assistant.

Connecting Home Assistant

We already have a working Home Assistant setup at home. It offers an Android Debug Bridge integration for ADB control, as well as a separate Android TV Remote integration that uses the TV's remote-control service.

The scripts below call the ADB command-line client through Shell Command, so neither TV integration is required for these examples. If you also want an ADB media-player entity, open Settings → Devices & services → Add integration, choose Android Debug Bridge, and enter the TV's IP address and port 5555. Approve its debugging authorization prompt on the TV, selecting Always allow from this computer.

Enable the Wake-on-LAN action by adding this to configuration.yaml, then restart Home Assistant:

wake_on_lan:

The script below sends the magic packet directly, and an automation starts it whenever the Harmony activity changes. There is no separate button to press.

Waking the TV and being able to send it commands are two separate events. Even adb devices could list the TV as connected while an actual shell command hung. So instead of trusting the device list or the media player's state, I check whether the TV can execute something:

timeout 3s adb connect 192.0.2.50:5555
timeout 3s adb -s 192.0.2.50:5555 shell echo ready

I run these commands through Home Assistant's Shell Command integration, inspect the returned output, and keep the retries in Home Assistant scripts.

Here is the wake-and-HDMI setup so far. First, save this helper as /config/tcl_tv_adb.sh, replacing the example IP address and checking the HDMI input URI for your TV:

#!/bin/sh
set -u

serial=192.0.2.50:5555
hdmi1_uri=content://android.media.tv/passthrough/com.tcl.tvinput%2F.TvPassThroughService%2FHW15

case "${1:-}" in
    probe|hdmi1|sleep) operation=$1 ;;
    *) echo 'Expected probe, hdmi1, or sleep' >&2; exit 2 ;;
esac

for executable in adb timeout; do
    if ! command -v "$executable" >/dev/null 2>&1; then
        echo "Missing executable: $executable" >&2
        exit 2
    fi
done

adb_ready() {
    # A device listed by `adb devices` can still have an unresponsive shell.
    timeout 3s adb connect "$serial" >/dev/null 2>&1 || :
    reply=$(timeout 3s adb -s "$serial" shell echo ha_tcl_adb_ready 2>/dev/null) || return 1
    [ "$(printf '%s' "$reply" | tr -d '\r')" = ha_tcl_adb_ready ]
}

send_command() {
    if result=$(timeout 5s adb -s "$serial" shell "$@" 2>&1); then
        # `am start` can report a launch failure even with exit status zero.
        case "$result" in
            *Error:*|*Exception*) ;;
            *) printf 'ok\n'; return ;;
        esac
    fi
    # A disconnect or timeout while the TV wakes is an expected result.
    # Keep it out of stderr and return success to Home Assistant.
    printf 'failed\n'
    return 0
}

case "$operation" in
    probe)
        if adb_ready; then
            printf 'ready\n'
        else
            printf 'unavailable\n'
        fi
        ;;
    hdmi1)
        send_command am start -W -a android.intent.action.VIEW -d "$hdmi1_uri"
        ;;
    sleep)
        if adb_ready; then
            send_command input keyevent 223
        else
            printf 'unavailable\n'
        fi
        ;;
esac

The helper returns ready or unavailable for a probe, and ok or failed for a command. An offline TV, a timeout, or a disconnect between the probe and the HDMI command produces a normal response with exit status zero and no stderr output, so Home Assistant can retry without logging a shell-command error. Missing tools and invalid operations still produce errors so configuration mistakes remain visible.

Add the helper to configuration.yaml (merge it into an existing shell_command: section if you have one), then restart Home Assistant to load it:

shell_command:
  tcl_tv_adb: '/bin/sh /config/tcl_tv_adb.sh "{{ operation }}"'

Then add this to scripts.yaml, replacing the example MAC address with the TV's Ethernet MAC:

tcl_tv_on_hdmi1:
  alias: TCL TV - Turn on and select HDMI 1
  mode: restart
  sequence:
    - action: wake_on_lan.send_magic_packet
      data:
        mac: "02:00:00:00:00:50"

    - repeat:
        count: 10
        sequence:
          - action: shell_command.tcl_tv_adb
            data:
              operation: probe
            response_variable: tcl_adb_probe
          - if: "{{ tcl_adb_probe.stdout | trim == 'ready' }}"
            then:
              - action: shell_command.tcl_tv_adb
                data:
                  operation: hdmi1
                response_variable: tcl_hdmi_result
              - if: "{{ tcl_hdmi_result.stdout | trim == 'ok' }}"
                then:
                  - stop: HDMI 1 selected successfully.
          - if: "{{ repeat.index < 10 }}"
            then:
              - delay: "00:00:04"
    - stop: TV did not become ready or HDMI selection failed within ten attempts.
      error: false

Exhausting the retries also stops normally (error: false); the reason remains available in the script trace.

The startup sequence now sends Wake-on-LAN, waits for an ADB probe to succeed, then requests HDMI 1. The helper checks whether the launch command succeeded, and the script retries if it did not.

After all this work, we can now tie ADB together with the Harmony commands.

Harmony and ADB, in perfect harmony

Like the TV, the Harmony Hub needs a static DHCP mapping so that Home Assistant can find it.

Then add the built-in Logitech Harmony Hub integration:

  1. Open Settings → Devices & services and configure the discovered Harmony Hub. If it has not been discovered, select Add integration → Logitech Harmony Hub and enter its reserved IP address when prompted.
  2. If the connection requires it, enable XMPP in the Harmony app under Menu → Harmony Setup → Add/Edit Devices & Activities → Remote & Hub → Enable XMPP.
  3. Find the integration's activity selector and check its entity ID and the activity names it exposes. Mine is select.harmony_hub_activities, with TV, PC, Wii, Chromecast, and power_off.

This integration makes Home Assistant aware of the commands you send from the Harmony remote, which lets you kick off automations like this:

- id: harmony_tcl_adb
  alias: Harmony TCL network backup
  description: Mirror Harmony activities over ADB
  mode: restart
  triggers:
    - trigger: state
      entity_id: select.harmony_hub_activities
      to:
        - "TV"
        - "PC"
        - "Wii"
        - "Chromecast"
      id: tv_on
    - trigger: state
      entity_id: select.harmony_hub_activities
      to: "power_off"
      id: tv_off
  actions:
    - action: script.turn_off
      target:
        entity_id: script.tcl_tv_on_hdmi1
    - choose:
        - conditions:
            - condition: trigger
              id: tv_on
          sequence:
            - action: script.turn_on
              target:
                entity_id: script.tcl_tv_on_hdmi1
        - conditions:
            - condition: trigger
              id: tv_off
          sequence:
            # Give Harmony time to finish its IR power toggle first.
            - delay: "00:00:02"
            # Check the TV's state after the delay, before sending the backup.
            - condition: template
              value_template: >-
                {{ states('media_player.smart_tv_pro') in ['on', 'idle', 'playing', 'paused', 'buffering'] }}
            - action: shell_command.tcl_tv_adb
              data:
                operation: sleep

Every matching activity change cancels any pending wake-and-HDMI retries first. Video activities start the script without waiting for it to finish. Power Off waits two seconds, then checks whether the TV still reports an active state before sending the ADB sleep command. An off, unknown, or unavailable TV is left alone.

For this state check, I use media_player.smart_tv_pro, the TV entity from the Android TV Remote integration. Replace it with your own TV entity; the shell commands alone do not provide this entity.

I also added the delay because Harmony sends an IR power toggle for shutdown. If ADB puts the TV to sleep first and the IR command arrives afterward, that toggle can turn it back on. Giving IR two seconds to finish, then checking the TV's state, makes ADB a backup for a missed shutdown. The delay lives in the automation in these examples, so mode: restart also cancels a pending shutdown if someone switches activities.

With this setup, we now have a very resilient media experience. A user presses a button on the Harmony remote, which sends IR commands. In parallel, Home Assistant sees the Harmony state change and sends ADB commands over wired Ethernet. If one of them fails, the other takes over. This means that if Home Assistant is down for maintenance, the TV can turn on using IR codes. If an IR code gets lost due to direct sunlight, Home Assistant takes over.

Sure, if both IR and Home Assistant are down, this will fail, but we have greatly reduced the probability of total failure.

Music without the TV

Our Chromecast is plugged into the Denon receiver, so it can supply music directly to the receiver and speakers while the TV is off. I don't like being required to have a TV screen on just to listen to music. I'm old enough to have listened to records, tapes, and CDs, and I don't want my kids to always associate "Music" with "I can look at a screen", even if the album art is great.

In Harmony, create a new activity called "Music" that includes the receiver, leaves the TV off, and selects the receiver's Chromecast input. Cast the music to the Chromecast; the automation below only handles keeping the TV off, not starting playback. With ADB, we modify our automation to send the TV to sleep when we select Music:

    - trigger: state
      entity_id: select.harmony_hub_activities
      to:
        - "Music"
        - "power_off"
      id: tv_off

With this, both Music and Power Off cancel pending wake-and-HDMI work, wait two seconds, and send the ADB sleep command only if the TV still reports an active state. This prevents pending startup retries from turning the TV back on while we are listening to music.

Automatic low-latency Game mode

I normally use Filmmaker mode on the TV since it has the best visual performance for watching movies. However, it adds latency due to added signal processing, so we want to switch to Game mode when we are playing games. You can't beat a Super Meat Boy level if your TV adds all those milliseconds to the displayed output. There is no other reason I keep on dying on that level, right?

The TV supports Auto Low Latency Mode (ALLM), which lets a compatible source request low-latency processing over HDMI. However, neither our Nintendo Wii nor our old Haswell-based gaming PC provides an ALLM signal in this setup, and the old receiver does not support passing it through either. We therefore need another way to select Game mode.

Again, ADB comes to the rescue. From the previous section, Home Assistant already knows which activity is selected on the Harmony remote, so we can make it force Game mode when we switch to the PC or Wii activities.

Next, we need to find which ADB commands select Game and Filmmaker modes. I could not find a documented ADB command for this. Credit goes to Reddit user u/Fatel28 for reverse-engineering TCL code and finding a solution for their TCL QM7K TV. It turns out that these commands also work on my TV.

To read the current picture mode:

adb shell service call tcl_tv_display 27

For me, Filmmaker mode returned 0000003c, which is hexadecimal for decimal 60. Game mode returned 00000005, or 5. These commands then switched the TV between them:

# Game mode
adb shell service call tcl_tv_display 26 i32 32 i32 5 i32 2 i32 2

# Filmmaker mode
adb shell service call tcl_tv_display 26 i32 32 i32 60 i32 2 i32 2

Before changing the automation, we need a script that actually applies the preset. First, extend /config/tcl_tv_adb.sh to accept game and filmmaker in its initial operation check:

case "${1:-}" in
    probe|hdmi1|sleep|game|filmmaker) operation=$1 ;;
    *) echo 'Expected probe, hdmi1, sleep, game, or filmmaker' >&2; exit 2 ;;
esac

Add this function before the helper's final dispatch block. It sets the preset and reads it back, returning failed quietly if the TV is unavailable or the change did not take effect:

set_picture_mode() {
    case "$operation" in
        game) mode_id=5; expected_mode=00000005 ;;
        filmmaker) mode_id=60; expected_mode=0000003c ;;
    esac
    if ! result=$(timeout 5s adb -s "$serial" shell service call tcl_tv_display 26 i32 32 i32 "$mode_id" i32 2 i32 2 2>&1); then
        printf 'failed\n'
        return
    fi
    if ! result=$(timeout 3s adb -s "$serial" shell service call tcl_tv_display 27 2>&1); then
        printf 'failed\n'
        return
    fi
    actual_mode=$(printf '%s\n' "$result" | sed -n 's/.*Parcel([[:space:]]*00000000[[:space:]]*\([[:xdigit:]]\{8\}\).*/\1/p')
    if [ "$actual_mode" = "$expected_mode" ]; then
        printf 'ok\n'
    else
        printf 'failed\n'
    fi
}

Add this branch to the final case "$operation" in block, before esac:

    game|filmmaker)
        set_picture_mode
        ;;

In scripts.yaml, replace tcl_tv_on_hdmi1 with the updated version below and add tcl_tv_set_picture_mode. The picture-mode script has its own readiness probes and bounded retries, so a failure in the wake-and-HDMI script does not prevent picture-mode selection:

tcl_tv_on_hdmi1:
  alias: TCL TV - Turn on and select HDMI 1
  mode: restart
  sequence:
    - action: wake_on_lan.send_magic_packet
      data:
        mac: "02:00:00:00:00:50"

    - repeat:
        count: 10
        sequence:
          - action: shell_command.tcl_tv_adb
            data:
              operation: probe
            response_variable: tcl_adb_probe
          - if: "{{ tcl_adb_probe.stdout | trim == 'ready' }}"
            then:
              - action: shell_command.tcl_tv_adb
                data:
                  operation: hdmi1
                response_variable: tcl_hdmi_result
              - if: "{{ tcl_hdmi_result.stdout | trim == 'ok' }}"
                then:
                  - action: script.turn_on
                    target:
                      entity_id: script.tcl_tv_set_picture_mode
                    data:
                      variables:
                        picture_mode: >-
                          {{ picture_mode | default('game' if states('select.harmony_hub_activities')
                             in ['Wii', 'PC'] else 'filmmaker') }}
                  - stop: HDMI 1 selected successfully.
          - if: "{{ repeat.index < 10 }}"
            then:
              - delay: "00:00:04"
    - stop: TV did not become ready or HDMI selection failed within ten attempts.
      error: false

tcl_tv_set_picture_mode:
  alias: TCL TV - Set picture mode
  mode: restart
  fields:
    picture_mode:
      name: Picture mode
      description: Defaults to Game for Wii/PC and Filmmaker for other activities.
      selector:
        select:
          options:
            - game
            - filmmaker
  sequence:
    - variables:
        desired_picture_mode: >-
          {{ picture_mode | default('game' if states('select.harmony_hub_activities')
             in ['Wii', 'PC'] else 'filmmaker') }}
    - condition: template
      value_template: "{{ desired_picture_mode in ['game', 'filmmaker'] }}"
    - repeat:
        count: 10
        sequence:
          - action: shell_command.tcl_tv_adb
            data:
              operation: probe
            response_variable: tcl_picture_probe
          - if: "{{ tcl_picture_probe.stdout | trim == 'ready' }}"
            then:
              - action: shell_command.tcl_tv_adb
                data:
                  operation: "{{ desired_picture_mode }}"
                response_variable: tcl_picture_result
              - if: "{{ tcl_picture_result.stdout | trim == 'ok' }}"
                then:
                  - stop: Picture mode applied and verified.
          - if: "{{ repeat.index < 10 }}"
            then:
              - delay: "00:00:04"
    - stop: TV did not become ready or picture mode did not apply within ten attempts.
      error: false

There is an extra detail in the updated wake-and-HDMI script: after HDMI 1 is selected successfully, it starts the picture-mode script again. Switching inputs can restore a saved preset, so this second run reapplies the desired mode to the selected input. The automation also starts picture-mode selection independently, so it can still work if Harmony selects the input over IR while the network HDMI command fails.

Next, I modify the Harmony automation to start both scripts independently. Replace the earlier automation with this version, using your own activity names:

- id: harmony_tcl_adb
  alias: Harmony TCL network backup
  mode: restart
  triggers:
    - trigger: state
      entity_id: select.harmony_hub_activities
      to:
        - "TV"
        - "PC"
        - "Wii"
        - "Chromecast"
      id: tv_on
    - trigger: state
      entity_id: select.harmony_hub_activities
      to:
        - "Music"
        - "power_off"
      id: tv_off
  actions:
    - action: script.turn_off
      target:
        entity_id:
          - script.tcl_tv_on_hdmi1
          - script.tcl_tv_set_picture_mode
    - choose:
        - conditions:
            - condition: trigger
              id: tv_on
          sequence:
            - action: script.turn_on
              target:
                entity_id:
                  - script.tcl_tv_on_hdmi1
                  - script.tcl_tv_set_picture_mode
              data:
                variables:
                  picture_mode: >-
                    {{ 'game' if trigger.to_state.state in ['Wii', 'PC'] else 'filmmaker' }}
        - conditions:
            - condition: trigger
              id: tv_off
          sequence:
            # Give Harmony time to finish its IR power toggle first.
            - delay: "00:00:02"
            # Check the TV's state after the delay, before sending the backup.
            - condition: template
              value_template: >-
                {{ states('media_player.smart_tv_pro') in ['on', 'idle', 'playing', 'paused', 'buffering'] }}
            - action: shell_command.tcl_tv_adb
              data:
                operation: sleep

Both scripts use mode: restart, with up to ten attempts and four seconds between failed attempts. They stop after success. Changing activities cancels the pending jobs before starting new ones, so a slow Wii startup does not apply Game mode after you have switched to watching TV. The shutdown branch keeps the same two-second delay and TV-state check, and switching activities during that delay cancels the pending shutdown.

Summary

Can you turn a smart TV on and off? Yes, but only after reading a lengthy blog post! I am amazed at how smartness makes it more difficult to use our technology at home. Why do TVs no longer support discrete IR power commands?

Anyway, with this setup, we have greatly increased the reliability of our Harmony setup. With only one nice remote, we can watch TV, play music, game, and turn the whole system off. Audio goes through our media receiver, which handles amplification and speaker optimization.

Another advantage is performance. With IR codes only, things are pretty slow because Harmony has to send one command, wait, then send the next. It is fire-and-forget, so it can't know when a command succeeded. ADB, on the other hand, works quickly over Ethernet and provides feedback, enabling closed-loop control. In my testing, I have been able to shave off several seconds on every startup, shutdown, and mode switch. This adds up!

The downside is still ongoing maintenance. If I change a Harmony setting, I have to modify Home Assistant as well. Luckily, that is something that only falls on me, so nobody else is bothered by it.

If you found this useful, give me a shout on Twitter (@Jogenfors). Thanks for reading!

https://jogenfors.com/posts/atom.xml