Instruction: Hyperion -> HA-Bridge -> Home Assistant

Hi all, i’ve created a manual that describes how to connect an existing Hyperion setup to an existing Home Assistant setup. By doing this, i wanted to create a next level Ambilight experience. My situation:

  • I have a Raspberry Pi 4 connecting to a ledstrip (ws2812b) via the GPIO pin 18. The Raspberry runs Hyperion (in combination with a cheap HDMI USB grabber). The effects of this are very nice.

  • I have another Raspberry Pi 4 running Home Assistant (docker supervised). There are many lights connected to it, some via zigbee, some via wifi.

I wanted my ‘normal’ zigbee/wifi lights to also respond to the tv screen. Therefore, i needed both Raspberries to talk to each other.

  • I tried doing this by installing “Emulated Hue” from the Home Assistant Add-on store. But i got stuck there, since the required port (80) is of course already occupied. I read over the forums that this is the case for many people, and many people got stuck there (me included).

  • Therefore, i looked at an alternative: HA-Bridge. I’ve installed HA-Bridge on the other Raspberry PI (the one that is already running Hyperion).

  • I’ve setup HA-Bridge. You can find below how to do that:

HA-Bridge setup
Generic “Bridge Control” Settings, section “HomeAssistant Names and IP Addresses”

  • Name: Home Assistant (can be any name)
  • IP: 192.168.2.21 (ip address of your Home Assisant device)
  • Port: 8123 (is usually 8123)
  • Token/Password: your_super_secret_token
  • Auth Type: do not select “Legacy password”
  • Use SSL: do not select this option

→ Save > wait for 10 seconds: the Bridge is reinitializing, but this message stays forever > “Bridge Stop” → rerun HA-Bridge (if you installed HA-bridge up correctly, this will happen automatically when rebooting the device running HA-Bridge). After reboot, do the following:

  • Add your devices using the tab “HomeAssistant Devices”: select them and click on Build Item. Save with the green button on top.
  • Under “Bridge Devices”, you can press Edit/Copy. This will bring you to the next screen, at which you should add the settings as explained below:

On Items:

  • Type: HTTP Device
  • Target Item: http://192.168.2.21:8123/api/services/light/turn_on (please replace with the ip-address of your device running Home Assistant)
  • Delay: empty
  • Count: empty
  • Filter IP’s: empty
  • HTTP Verb: POST
  • HTTP Body: {“entity_id”:“light.woonkamer_subwoofer”,“transition”:0.5}
  • HTTP Headers: [{“name”:“Authorization”,“value”:“Bearer your_super_secret_token”}]
  • Content Type: application/json

As you can see, my device is “light.woonkamer_subwoofer”. Please change this to your entity_id of interest (the entity id as it is named in Home Assistant itself). This remark naturally applies also to the rest of the settings below.

Dim Items:

  • Type: HTTP Device
  • Target Item: http://192.168.2.21:8123/api/services/light/turn_on (please replace with the ip-address of your device running Home Assistant)
  • Delay: empty
  • Count: empty
  • Filter IP’s: empty
  • HTTP Verb: POST
  • HTTP Body: {“entity_id”:“light.woonkamer_subwoofer”,“transition”:0.5,“brightness”:${intensity.byte}}
  • HTTP Headers: [{“name”:“Authorization”,“value”:“Bearer your_super_secret_token”}]
  • Content Type: application/json

Off Items:

  • Type: HTTP Device
  • Target Item: http://192.168.2.21:8123/api/services/light/turn_on (please replace with the ip-address of your device running Home Assistant)
  • Delay: empty
  • Count: empty
  • Filter IP’s: empty
  • HTTP Verb: POST
  • HTTP Body: {“entity_id”:“light.woonkamer_subwoofer”,“transition”:0.5}
  • HTTP Headers: [{“name”:“Authorization”,“value”:“Bearer your_super_secret_token”}]
  • Content Type: application/json

Color Items:

  • Type: HTTP Device
  • Target Item: http://192.168.2.21:8123/api/services/light/turn_on (please replace with the ip-address of your device running Home Assistant)
  • Delay: empty
  • Count: empty
  • Filter IP’s: empty
  • HTTP Verb: POST
  • HTTP Body: {“entity_id”:“light.woonkamer_subwoofer”,“transition”:0.5,“rgb_color”:[${color.r},${color.g},${color.b}],“brightness”:${intensity.byte}}`
  • HTTP Headers: [{“name”:“Authorization”,“value”:“Bearer your_super_secret_token”}]
  • Content Type: application/json.

I’m linking here to a topic on this forum: HA Bridge with auth token ,that gave me important clues how to do this. I hope this explanation will help others. See also the same information here: rgb support for HomeAssistant · Issue #1294 · bwssytems/ha-bridge · GitHub , this is also the place were you can find the latest version of HA-Bridge.

Note 1: please be aware that you need to drastically reduce the update frequency in Hyperion for your zigbee and wifi lights (especially the wifi lights). Whereas the ledstrip (ws2812b) is supposed to provide very fast (<20ms ) responses (which it can easily handle via the GPIO-interface), you should not overflood your regular wifi/zigbee lights: i am keeping it to one update per second for these lights. This is actually also nicer to look at: if normal lights are blinking very fast, it breaks the mood. The fast-pacing effects should be handled from the ledstrip projecting to your backwall.

Note 2: there are excellent instructions online that shows you how to setup a ledstrip ws2812b to Hyperion. Thank you Dr Zzs!

Note 3: you can install the Hyperion Home Assistant Integration as well. This provides you with the option to enable/disable the hyperion effects. In my setup, i’ve two “chunks” of led hardware running (the ledstrip ws2812b, and the mood-lighting via wifi/zigbee lights). The “chunks” are called “instances” in Hyperion. The Hyperion integration allows you to enable/disable these individual instances from the front-end of Home Assistant. Very handy.

I’ll try to make a video of the end-result at a later moment. It is very spectacular:

  • the ledstrip (ws2812b) providing fast-paced precise light effects

  • Multiple zigbee and wifi lights providing slower-paced mood effects.

11 Likes

Hereby a demo. It is even more detailed in real-life than displayed here (its recorded with a smart phone, there is only so much that it can capture). For your reference: my tv is a 42 inch Panasonic plasma screen, it gets dwarfed by the wide-spread lighting effect.

I’ve done some more calibration to add more vibrant colors. I think this will give a good impression of what you can expect.

2 Likes

Nice work. I have my ws2812b led strip just controlled by a $2 esp board (running esphome). Hyperion.NG runs directly on my kodi box and uses the “internal” grabber (so no extra hardware needed here) :tada:

In all my ambilight clone had a total cost of around $8 for a 32" screen (used about 2.5m led strip and a d1 mini clone)

Nice! Always interesting to see other solutions and setups :tada:

Hi @pimw great write up, thanks for taking the time. Just had a question as to how to find the Home Assistant auth token to begin with?

You can find it here: Authentication - Home Assistant
It’s the part about “Long-lived access token”.

After you click on your profile within Home Assistant (left bottom), you can scroll all the way down to create a long-lived access token.

How did you @pimw manage to let Hyperion connect to HA-Bridge? Also, I am trying to use a Shelly bulb which is already working in Home Assistant. How did you debug the call? Should I talk to Home Assistant or directly to the bulb.

The default config in ha-bridge let me toggle the light, but not change color. Your setting didn’t work for my bulb.

How’s the latency? I found the GoogleTV/Android software grabber was too slow to be usable, even with wired lan. Also interested where you sourced 2.5m of LEDs and a power supply for $6 :stuck_out_tongue:

Where did you find this setting? I’m trying to get Hyperion to run effects on four LIFX bulbs rather than running USB capture, but it seems like your config should handle both fine. I’ve been able to add the bulbs to the bridge, get those added as a second instance in Hyperion, and use the basic controls.

I can even start an effect just fine, but when I try to make changes after that, it is very unpredictable; can take minutes or dozens of minutes to apply, might only apply to some bulbs, might not apply at all etc. I don’t have a strong idea what’s causing this but I wouldn’t be surprised if either the wifi or the bulbs are being overloaded with a volume of requests that’s intended for GPIO not wifi.

It seems like the Entertainment API might be intended for more frequent updates, but according to the Hyperion UI it needs groups configured on the Hue bridge, and I couldn’t find any way to do that in HA Bridge

No Problem at all, no visible lag over wifi. I use the integrated (hardware?) amlogic grabber in my coreelec box (s905x3, 2gb ram, 16gb flash I sourced for $25 back in the days).

If I remember right I paid around $10 (with free shipping) for 5m ws2812b strip (60leds/m, ip30) from the country where this stuff is produced (:flag_cn:). This was before chip shortages, increasing shipping fees and with vat free import.

The power supply was sourced from my drawer and is just a random ordinary USB plug (2.4A/5V).

I don’t think this is working anymore. I have configured my lights exactly like you said but they’re not turning on or off. All I can see in the logs is this error: “spark.http.matching.GeneralError”. Any ideas?

The issue with the code is that the quotation marks are getting f’d up. Both the @pimw 's post on github and this forum appears wrong for me. I’m going to screenshot to remove any issues, but the key points are (1) to make sure all double quotes are the normal straight " ones and not ” or “ (2) there is some weird angled single quote at the end of the HTTP body; this isn’t needed.

Here’s the config that I used in ha-bridge. Hope it helps.

This is a setup for a lightbulb that only supports dimming, no rgb.

On Items

  • Type: HomeAssistant device
  • Target item: `{“entityId”:“light.led_salon_1_light”,“hassName”:“myhome”,“state”:“on”}

Dim Items

  • Type: HTTP Device

  • Target item: http://192.168.0.5:8123/api/services/light/turn_on (replace IP with the proper one)

  • HTTP Verb: POST

  • Http Body:

    {"entity_id":"light.led_salon_1_light","brightness":${intensity.byte}, "transition": 0.125}
    
  • HTTP Headers:

    [{"name":"Authorization","value":"Bearer the_secret_token"}]
    
  • Content Type: application/json

Off Items

  • Type: HomeAssistant device
  • Target item: `{“entityId”:“light.led_salon_1_light”,“hassName”:“myhome”,“state”:“off”}

Color Items

  • Type: HTTP Device
  • Target item: http://192.168.0.5:8123/api/services/light/turn_on (replace the IP)
  • HTTP Verb: POST
  • HTTP Body:
    {"entity_id":"light.led_salon_1_light","brightness":${intensity.byte}, "transition": 0.25}
    
  • HTTP Headers:
    [{"name":"Authorization","value":"Bearer the_secret_token"}]
    
  • Content Type: application/json

I am struggling pretty hard to setup the HA Bridge in Hyperion / HyperHDR. Everything on the HA Bridge side is working and now I only need to connect HyperHDR to the HA Bridge.

Problem 1:
HyperHDR finds the Hue Bridge IP without problems, but asks for a client ID and clientkey. I don’t have those and I don’t know where to get them.

Problem 2:
Even without the client id and clientkey HyperHDR correctly grabs the HA Bridge lights with IDs. I can choose positions for them, but the identify buttons (“light led up blue”) don’t work and I also can’t click the save button in the Philips Hue Wizard in HyperHDR.

Problem 3:
HyperHDR says I need to “First set up your Philips LED lamps using the Philips mobile app: during setup, select the ENTERTAINMENT group for your lamps (you should get the ID of this group).”
I can’t connect HA Bridge to the Philips Hue App to do that, because the Hue App asks me to press a button on the Hub. I can’t find a button in the HA bridge Web Interface.

Am I doing something completely wrong?

@pimw @kuba-orlik Can you please let me know how you got around these issues?

I figured it out. The answer was to uncheck the “Use Hue Entertainment API”. Passwort ot clientkey aren’t needed with that.

After configuring the 4 LEDs (Tapo L530) and giving them a position in the hue setup wizard things start to work magically. Although I won’t use these LEDs in the future, because they don’t support light transitions and everything looks really bad with them suddenly changing colors.
I will stick with my classic low input lag 2812b for now.

I gave up ha-bridge in favor of a smaller, lighter, easier to configure alternative that I’ve coded:

I have made an feature request on the hyperion.ng repo here: Add Home Assistant support · Issue #1703 · hyperion-project/hyperion.ng · GitHub