Interfacing A Cheap HDMI Switch With Home Assistant

Close-up of the mod installed into the HDMI switch, tapping the IR receiver

You know the feeling of having just created a perfect setup for your hacker lab? Sometimes, there’s just this missing piece in the puzzle that requires you to do a small hack, and those are the most tempting. [maxime borges] has such a perfect setup that involves a HDMI 4:2 switch, and he brings us a write-up on integrating that HDMI switch into Home Assistant through emulating an infrared receiver’s signals.

overview picture of the HDMI switch, with the mod installed

The HDMI switch is equipped with an infrared sensor as the only means of controlling it, so naturally, that was the path chosen for interfacing the ESP32 put inside the switch. Fortunately, Home Assistant provides the means to both receive and output IR signals, so after capturing all the codes produced by the IR remote, parsing their meaning, then turning them into a Home Assistant configuration, [maxime] got HDMI input switching to happen from the comfort of his phone.

We get the Home Assistant config snippets right there in the blog post — if you’ve been looking for a HDMI switch for your hacker lair, now you have one model to look out for in particular. Of course, you could roll your own HDMI switch, and if you’re looking for references, we’ve covered a good few hacks doing that as part of building a KVM.

40 thoughts on “Interfacing A Cheap HDMI Switch With Home Assistant

  1. “got HDMI input switching to happen from the comfort of his phone.”

    Using a remote is surely better and faster than turning on the phone, opening an app and so on.
    That is not home automation.

    On the other hand, having the ability for the HDMI input to change automatically depending other conditions/triggers, that is home automation. For example, if the doorbell rings, and the TV is on, pause what is playing on the TV, and switch the HDMI input to the channel with the stream from the camera on the front porch.

    1. Ah yes, the author must have gone out of his way to make his life *worse*, because you obviously know the perfect solution despite not having read a single thing about their environment! You even missed the part where this is installed in a lab, not someone’s house.

      For one thing, you are likely to always have your phone on you, whereas the remote could be anywhere or lost or flat. They also have many people using the HA instance for other tasks, and there is a tablet set up specifically for easy access. But nooooooo, none of that should get in the way of your opinion!

      1. You successfully managed to recreate in your own mind a completely false picture of my comment, and just show yourself as very rude, Or to use your own words ” But nooooooo, none of that should get in the way of your opinion!”

        I didn’t criticize the author of the hack in any way. What I did was comment on the article suggesting that the only use for this is to control the HDMI switch from a phone instead of a remote.
        I also offered an example of how home automation can be used, as I do use Home Assistant at home, which coincidentally is also the most common place to use it.

        1. Sorry friend, but between your original comment and pelrun’s reply, yours is the one that came across as unnecessarily negative.

          The article was just sharing a neat little hack. Maybe you didn’t realize it, but your reply came across as nitpicky, overly critical, and rude. Yes, perhaps some of the replies to your post had some attitude as well, but that tends to happen in response to unnecessary negativity.

          In the future, maybe just try to say something positive before you point out minor semantic details and proceed to explain how you’d do it better. Then your comment may be better received. :)

        2. Ignore the other guy. A big brain move here would be to add a push switch r, and have the ESP monitor the button if pressed.

          That way he could push a physical a button to change HDMI

      2. Yup the switch is also likely out of line of sight. I bet it even has a blue LED ensuring no one would want it anywhere visible.

        Let alone the issue of losing the control.

    2. “Home Automation” is the name of the software, which controls devices, monitors sensors, and yes does all the orchestration in between to perform complex processes based on conditions or triggers.
      The software also can integrate with your network and thus any/all devices on it.

      So yes it is HA controlling the hdmi switch with the phone being one of the input methods.
      It can also do all the other stuff you list (assuming ofc their doorbell is linked to HA)

      1. Home assistant is the name of the software.

        And yeah, it’s just esp32’s doing something that could have been done with the push of a button.

        This is my one thing. Just let me have it, ok?

    3. A remote is better in case you’re already holding that remote in your hand, but it’s worse in any other case. Plus, the scenario you wish for, is now trivial – now, say, if your HA system detects a doorbell ring, it’s trivial to switch the HDMI port to a device displaying the front door camera!

      1. That is exactly my point. In the article you suggest that the addition of the EPS32 is only to use a phone to control the switch, while a whole new world is available.
        The only time where not using a remote is superior is when automation is actually involved, or you have lost the remote.

      1. This is such a cool idea. I currently have 4 HDMI switches hooked up to a Logitech Harmony and I hate how over complicated it’s gotten. I wrote some nodejs scripts to control the switcher using the harmony API but it’s so flakey. Light conditions, kids or toys blocking the sensors.. one mistake and the whole thing falls apart. What I would love to see is a USB or HTTP interface for these switchers. I lack the electronics experience to do what I want, but someone here could probably set me straight. A way to read which LED is on = determine which input is active. A way to “hit the selector button” would let me select the input I want. This article covers the last part, but perhaps reading the selected device is easier than doing the code emulation?

  2. I have a similar setup with a Navceker 4×2 HDMI matrix and a Wemos D1 Mini running Tasmota. Beware the IR remotes on cheap devices, as they can interfere in unexpected ways. One of the buttons to change inputs on my matrix’s remote just happens to reliably reset my audio amp to factory settings, and another one sets the volume at 85%. That isn’t fun to debug.

  3. For a long time I thought that using a phone to control a TV or stereo is just plain stupid. Why unlock your phone, connect to wifi, find the app etc. when you can just grab a remote and off you go. I made an arduino IR remote controller / source switch for my vintage JVC AX-2 / T-2XL and used it for a long time. Then I put in an ESP8266 and connected it to MQTT. And guess what? The phone is always connected to wifi because I need spotify anyway, And it is within my reach whereas remotes are gathering dust somewhere. This way smartphone killed yet another appliance.

  4. I have used a similar hack to allow switching between different cameras on prototype UAV payloads. Flipping a UAV remote controller switches changes the output of the flight controller on the aircraft which is tied to an input on the Arduino, the Arduino translates this into HDMI input Channel # from the HDMI switch. Rather than IR, the Arduino ‘presses’ the channel select button on the HDMI switcher (tied to board output) to switch channels, then looks to see if the appropriate output LED for that channel (tied to board input) is lit. Otherwise it keeps pressing the button until the HDMI switcher matches the commanded channel.

  5. True (the above comments). But what this does is open the door to what I really miss from my old entertainment system. W/o naming names, I now look back w/a bit of “that was actually really nice” at being able to take one action and having the correct equipment power up and connect.

    True, we (many of us) no longer pop in a disc let alone push in a tape to start things off. But, w/HA in the loop & your phone, I can see pushing one button for a certain media company and having the TV, AV, Stick & HDMI multiplexer all turn on and configured just right for the viewing.

  6. I did something similar with a cheap hdmi kvm connected to my pikvm to get two inputs. It’s a small esp32 running esphome connected to the internal uart that just sends the toggle command over serial when I hit a button in home assistant. I could’ve probably done something inside pikvm but this was my simple amd lazy solution.

  7. I did this a year ago to some 4K HDMI switches for game console integration. I wanted to be able to still manually control via the remote but I needed the automation system to also be able to know what input they were on and adjust accordingly.

    I ended up just throwing an ESP chip in there and put the LED leads into Arduino inputs to sense what input was selected and to detect if the switch was in Auto or Manual modes. Then I soldered transistors to each of the front panel buttons so the ESP could control them. A quick MQTT script to read and control inputs was all it needed after that.

    Now turning on the PS3 causes the current sensor to detect draw, that triggers the automation to flip the HDMI input on the switch, turn on the TV, flip that input, turn on the amp, flip that input and adjust the volume to a preset level, then light up a set of RGB leds around the cubie hole the PS3 is in. I have that setup for 32 different gaming consoles, turning any console on flips all the right inputs and pops up the video on the display… it even loads the right scaling settings on my scaler for the older consoles.

  8. What I think is notable about this is that he is not using any actual IR transmitters to send the signals. The ESP32 is directly connected to the signal line of the IR *receiver*, and emits appropriate signals *as though* the IR receiver has demodulated them from the transmitter. There is no IR to interfere with other devices as mentioned by another poster. This could operate in direct sunlight with no degradation, for example.

    This is a handy technique, using a microcontroller to emulate a physical component. Whether it is an IR receiver, some peripheral that talks serial over UART, etc, etc, the microcontroller provides a lot of flexibility in interfacing, while still not having to go too low level (e.g. rewriting the firmware in the HDMI switch’s microcontroller).

  9. Cute, I like the idea that I could fit an ESP32 to any IR controlled device and have it web controlled.

    Might dig out my old Shinwa scanner and see if I can’t work out the IR protocol

    1. Definitely… I haven’t looked into it, but it sure seems like there could be a generic ESP32 image that would just transmit IR signals on MQTT as they come in and accept MQTT signals to pass into the device as an IR signal… Basically, a “plug and play” device you can wire to the IR pins that would tell you what MQTT signals you need to send it any time you used the IR remote, and you could just store those same signals to send back over MQTT using Home Assistant.

      I have some air cleaners in the shop that I may need to do this with… Would love to set them on a regular interval and also turn on automatically when the air quality drops below a threshold…

  10. Hey thanks for the article :)
    Indeed this is installed in our hackerspace in Geneva, Switzerland. We have a lot more stuff connected to Home Assistant already, and a (now dead) Android tablet that was easier to reach than both the switch and the usual place for the remote (now that you say it, I’m not even sure where the remote is…)
    Also one of the plan was to connect a few things to a vocal assistant, like controlling the light brightness and ventilation system of the lab, and obviously the HDMI switch was part of it :)

  11. I have something similar but didn’t dare tap into the IR receiver circuit so instead I pull down the button pins and observe the LED pins of the front panel to interface with the device and determine its status. This has worked for a literal decade now (it’s toslink instead of HDMI but the devices are very similar interface wise).

  12. For me it has become a personal tradition at this point. Every new AC anyone in my family buys, I must open its remote, record the IR signal to turn on/off the AC, and implement it in an ESP32 or ESP8266.

    The first time I did it, I didn’t know anything about IR comm, and wrote my own firmware to capture the signal using an atmega micro. Now I just use an oscilloscope or logic analyzer

    I didn’t even know IR comm worked on a “carrier” so it came as a surprise when the code wasn’t as simple as “record the time between falling edges”

    1. Oh I didn’t even think about looking at HDMI CEC. I just tried some things quickly but it seems to miss some info to get the active input, which we don’t really get currently anyway.
      I’ll try to see if switching works once I go back to the lab ;)

    2. HDMI CEC is a great idea but in action it’s pretty broken because many many manufacturers dont implement it all correctly or even often partially.
      I went down that route and it frankly sucked – mostly for power off (power on generally worked).

  13. Article:
    “if you’ve been looking for a HDMI switch for your hacker lair, now you have one model to look out for in particular”

    Linked article:
    Material

    NoName 4 in/2 out HDMI switch
    —-

    Hah. Obviously you can use anything with a standard remote receiver in it, any noname device you might say. Just check if it uses 3.3 or 5 volt before connecting up.

  14. Found this and highly appreciate it.

    My use case is slightly different:
    Imagine a sports bar like lounge at a football club with 2 TVs & projector inside and an optional outside display.

    Sources are a SAT-Receiver, a Streaming box, a Miracast-Receiver for presentations and a stick for Digital Signage/Advertising.

    Audio is controlled via a SONOS Amps (One for the 4 inside speakers, one for the 4 outside Speakers)

    Everything can be controlled via KNX – Lighting, shutters, projection screen and even Sonos works via the KNX touchpanel.

    2 things don’t: The projector & the HDMI Matrix. So to complete the task (which is to lock the rack and tech room) I need an ESP32 that can control the HDMI switch via RS232 either via MQTT, Modbus or KNX/IP. Same for the Epson projector.

    My dream would be a universal esp32-based solution to send commands to any serial client be it RS232 or RS485 from KNX/IP, Modbus or MQTT.

    I know a lot of people working in professional building automation would appreciate this.
    Not sure if you plan to extend it this way, but a simple KNX-Serial Gateway sells currently for 300€. So there is even a viable commercial option.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.