bwssytems / ha-bridge

Home automation bridge that emulates a Philips Hue light system and can control other systems such as a Vera, Harmony Hub, Nest, MiLight bulbs or any other system that has an http/https/tcp/udp interface. This is a compact impl to run on small format computers. This is impl started from this project https://github.com/armzilla/amazon-echo-ha-bridge.
Apache License 2.0
1.45k stars 198 forks source link

rgb support for HomeAssistant #1294

Open ReneHezser opened 3 years ago

ReneHezser commented 3 years ago

I am unable to set the color on my Yeelight YLDL01YL Meteorite light. HomeAssistant does support it with its Yeelight integration and setting the color does work.

service: light.turn_on
data:
  entity_id: light.yeelight_ceiling10_0xyz_ambilight
  rgb_color:
    - 0
    - 255
    - 0

On, Off and Dim does work with "HomeAssistant Device" type.

{"entityId":"light.yeelight_ceiling10_0xyz_ambilight","hassName":"Home Assistant","state":"on"}
{"entityId":"light.yeelight_ceiling10_0xyz_ambilight","hassName":"Home Assistant","state":"on","bri":"${intensity.percent}"}
{"entityId":"light.yeelight_ceiling10_0xyz_ambilight","hassName":"Home Assistant","state":"off"}

Is setting the rgb color supported? I can't find it on the documentation or an example.

bwssytems commented 3 years ago

Take a look at this section https://github.com/bwssytems/ha-bridge#value-passing-controls

ReneHezser commented 3 years ago

Take a look at this section https://github.com/bwssytems/ha-bridge#value-passing-controls

I saw that part of the documentation and know that RGB is supported in multiple ways. What I do not see is why for example bri instead of brightness needs to be sent to HomeAssistant and following this, what do I need to set for RGB?

https://www.home-assistant.io/integrations/light/ meantions brightness and rgb_color. Where are they mapped here in HA Bridge?

brightness --> bri rgbcolor --> ```¯_(ツ)/¯```

pimw1 commented 3 years ago

Hi Rene, did you find any solution for this? I'm strugling with the same.

ReneHezser commented 3 years ago

Hi Rene, did you find any solution for this? I'm strugling with the same.

I have not tried any further.

pimw1 commented 3 years ago

Thanks for letting me know. @all: could someone please help us out?

My setup is straightforward:

Home Assistant can handle many different formats for color changes: hs_color, xy-color, rgb_color, rgbw_color, rgbww_color, color_name.

How do i pass a color-command? i've read the documentation very carefully, but i'm looking for a clear example.

These are my settings: image

This happens when i test: image But no color-change on the light bulb.

Please help me (and Rene :)) out. Any help is really appreciated.

pimw1 commented 3 years ago

Hi all, i am able to adjust the color light by calling the REST API directly:

curl -X POST \
  -H "Authorization: Bearer mysupersecrettoken" \
  -H "Content-Type: application/json" \
  -d '{"entity_id":"light.woonkamer_subwoofer", "brightness": 255,  "rgb_color":[255,255,50], "transition":0}' \
  http://192.168.2.21:8123/api/services/light/turn_on

How can i transform this in HA-Bridge? Any repsonse would be highly appreciated.

bwssytems commented 3 years ago

Could you turn on Trace State Changes in the Bridge Control Tab to see what it is sending? Thanks

pimw1 commented 3 years ago

Sure, thanks for helping me :) See the output below.

image

edit: when executing, the light turns on, but in full white, no color.

pimw1 commented 3 years ago

I think/hope that i've got a solution: i'm sending out the below http requests:

image

image

When testing, all four buttons are working (TEST ON, Test Dim, Test OFF, Test Color).

This was quite a challenge since i'm not a programmer (i had to learn on the fly how to use REST APIs plus combining that knowlegde with the usage of the HA-Bridge variables).

Edit: the black bars are my super secret Home Assisant token, i'd like it to stay super secret ;)

pimw1 commented 3 years ago

Hi, í've finetuned it a bit to get the smoothest response from Hyperion (with transition = 0.5). I also got to know that "color items" also need brightness variable in it (otherwise applications like hyperion can only change color but not birghtness). See below all settings that i am using.

Generic "Bridge Control" Settings, section "HomeAssistant Names and IP Addresses"

-> 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:

On Items:

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:

Off Items:

Color Items:

I'm linking here to a topic on the Home Assistant forum: https://community.home-assistant.io/t/ha-bridge-with-auth-token/93729 That gave me important clues how to do this. I hope this explanation will help others. The end-result is pretty spectacular: HDMI grabber ->Hyperion->HA-Bridge->Home Assistant ->

edit: i've created a more extensive manual on how to setup Hyperion-> HA-Bridge -> Home Assistant. You can find it here: https://community.home-assistant.io/t/instruction-hyperion-ha-bridge-home-assistant/307708