Fixing my Ambilight's Rainbow Color Phenomenon

Mar 9, 2019 3 min read
thumbnail for this post

I have a weird problem with my self-built Hyperion Ambilight: It shows rainbow colors when shutting down the AV Receiver and there is no HDMI signal anymore.

My workaround was to disable the entire construction (Raspberry Pi 3 + LED stripe) with a wall plug switch. The downside of this method is the system boot-up time so I couldn’t use it as a typical lightbulb. Another downside was the fact that the Raspberry Pi doesn’t like being turned off by pulling the power plug: It can destroy the entire SD card, but I was lucky and it never happened to me… Anyway, I need a better solution…

But why?

What causes this weird behavior? In the past, I didn’t bother where the rainbow colors came from, but to find an alternative solution I had to debug the entire construction. It was far easier than expected: Hyperion activates the LEDs for the specific HDMI signal. Since I was able to overwrite the rainbow colors with a black signal, Hyperion was fine. So I grabbed a screenshot of the HDMI input and Ta-da!
no signal splash screen

Urgh. Where does that come from? I pulled the plug between the HDMI Splitter and the Video Grabber and the problem was gone. After some research, I found out that it is typical for HDMI splitters to output no-signal images. Most of them are single-colored and so Hyperion can detect those and shut the LED stripe down. Well, I guess I’m lucky that someone decided to place a rainbow image in my HDMI splitter version… ;)

A simple solution

Hyperion added an option to detect the rainbow colors as no signal, but only in it’s newer development branch/repository that is still not stable since a few years… So it is time for a second workaround for this problem… My second worakround, and the current solution, is to leave the Ambilight active, but setting the color to black and the brightness to zero. I disabled the ambient background light for my Hyperion, so setting the color to black already disables the LED stripe and only the Raspberry Pi is still powered.

Automating the Workaround with Home Assistant

As mentioned above, when I want to turn the Ambilight off, I have to keep it active and set the color to black and the brightness to zero. Since different switches, scenes, automation etc turn the Ambilight entity off, I built an automation to re-enable the Ambilight:

  trigger:
    platform: state
    entity_id: light.ambilight
    to: 'off'
  action:
    - service: script.ambilight_off

The script does the following:

 ambilight_off:
  sequence:
    - service: light.turn_on
      data:
        entity_id: light.ambilight
        rgb_color: [0,0,0]
        brightness: 0

So everytime the entity is turned off, I reset the ambilight. So far so good…

The Ambilight resets itself to off

The automation works in theory, but after a few seconds, the Ambilight entity sets itself to off again without triggering the automation. The result? Rainbow colors, yay!

After a lot of scripting, hacking, and research, I stumbled upon this Github issue with the same problem.
Turns out there is some sort of race condition between Home Assistant and Hyperion’s frame grabber and we have to configure the priority in Home Assistant correctly.
Take a look at your Hyperion config and find the priority of your grabber:
locating the hdmi priority in the config

Then add this priority to your Home Assistant configuration as hdmi_priority:

  - platform: hyperion
    name: Ambilight
    host: !secret ambilight_ip
    hdmi_priority: 900

Now everything works as expected. \o/

Demo

Florian Brinker
I'm a Software-Developer based in Germany, enjoying home automation topics, microcontrollers, space- and quantum physics, astro- and landscape photography and mountainbiking.