Skip to content

Add Home Assistant Lights support #1763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Aug 25, 2024

Conversation

Lord-Grey
Copy link
Collaborator

@Lord-Grey Lord-Grey commented Jul 10, 2024

Summary

  • Add Home Assistant Lights support

A list of HA Lights can be mapped to one layout area currently.
For another capture areas an additional instance would be required.

It is recommended to set the latchtime to ensure that a certain time passes between two updates.
The solution cannot run with high fps and should only used for solitary lights, i.e. not the main ones.

Configure the device

  1. In preparation, create a Long-lived access token in Home Assistant
  2. Select Controller Type: homeassistant
  3. Hyperion tries to find your Home Assistant server. If not provide a custom hostname or IP-address
    4.Put the long lived token generated before in "Authorization Token"
  4. Select your HA light(s) from the list
  5. You might do "identify" to check, if the provided light light up
  6. Set the LED position in the layout using the wizard
  7. Save

See the screenshot below for reference

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Build-related changes
  • Other, please describe:

If changing the UI of web configuration, please provide the before/after screenshot:

Screen in default settings mode
image

Screen in Expert settings mode
image

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing setups:

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's body (e.g. Fixes: #xxx[,#xxx], where "xxx" is the issue number)

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature
  • Related documents have been updated (docs/docs/en)
  • Related tests have been updated

PLEASE DON'T FORGET TO ADD YOUR CHANGES TO CHANGELOG.MD

  • Yes, CHANGELOG.md is also updated

To avoid wasting your time, it's best to open a feature request issue first and wait for approval before working on it.

Other information:

Fixes #1703

@satgit62
Copy link

satgit62 commented Jul 21, 2024

@Lord-Grey

Hello,

Took the time to test the new “HomeAssistant” build.
I took the build branch from @Lord-Grey as a reference and built it for LG webOS. It worked right away and after the daemon start I got busy with the “HomeAssistant” LED controller in HyperHDR.

My short conclusion:

I can select all the lamps I have set up in Home Assistant and set them up in an instance. I have added another instance to an existing Ambilight instance of HyperHDR on “adalight” LED controllers with HyperSerial and set up two Home Assistant IDs. You can specify in the LED layout which position the lamps should have.
I also configured two additional instances for left and right. This also worked wonderfully.

I only have a simple Hue Bridge for the ZigBee lamps and via this, I have also integrated the Hue and other ZigBee compatible lamps into my Home Assistant.
This could cause a delay. With a short update interval and low FPS, the delay is kept within limits, and you won't be bothered by it. I don't know how this behaves with a real USB ZigBee Bridge. You also have to see whether you can address the lamps in Home Assistant via the entertainment area of the HUE so that the latency is reduced.

In any case, it is a super addition to the already extensive LED control of the Hyperion.NG. I hope @popy2k14 and other supporters will also test this project and share their experiences.
I'm also looking forward to completing the implementation and hope for further development. Many thanks again to @Lord-Grey for the quick implementation.

About Hyperion
Hyperion NG Controller 1_adalight
Hyperion NG Controller Homeassistant
About Hyperion

@Lord-Grey
Copy link
Collaborator Author

@satgit62 Just note, that currently the HA Light IDs will map only to the first LED in the layout.
Your screenshot indicates that you assume that ID1 will map to layout LED 0 and ID2 maps to layout LED 1.

@satgit62
Copy link

@satgit62 Just note, that currently the HA Light IDs will map only to the first LED in the layout. Your screenshot indicates that you assume that ID1 will map to layout LED 0 and ID2 maps to layout LED 1.

Yes, I know that, I found out.
I just wanted to see if two lamps can register at once under one instance.
But I also made separate instances and that works with the mapping, only I didn't take a screenshot of it.

@Lord-Grey
Copy link
Collaborator Author

Yes, the current way gives most flexibility.
You can have multiple lights for one instance and you can have many instances.

@eporsche
Copy link

@Lord-Grey

I would like to test your PR - however when I issue the command:
wget -qO- https://rg.gosu.cc/hyperion-project/hyperion.ng/master/bin/scripts/install_pr.sh | bash -s -- -t github_token -c ~/.hyperion 1763

I get this:
---> Download package for identified runtime architecture: arm64 and Qt6
---> The specified PR #1763 has no longer any artifacts.
---> It may be older than 14 days. Ask the PR creator to recreate the artifacts at the following URL:
---> #1763

Would you mind recreating the artifacts? Thank you very much! 😄

@Paulchen-Panther
Copy link
Member

Would you mind recreating the artifacts? Thank you very much! 😄

https://github.com/hyperion-project/hyperion.ng/actions/runs/9997312040?pr=1763

Once the workflow is complete, the artifacts should be available again.

@eporsche
Copy link

Installation worked - thank you!

@kylewhirl
Copy link

How do I install this on Hyperbian?

@eporsche
Copy link

@kylewhirl I followed this: https://docs.hyperion-project.org/user/advanced/Testing.html
However the first time I tried it - it overpowered my zigbee2mqtt / mosquitto server with requests - I need to play with the settings.

@Lord-Grey Lord-Grey merged commit 4f1b95e into hyperion-project:master Aug 25, 2024
18 checks passed
@popy2k14
Copy link

popy2k14 commented Sep 1, 2024

Guys, thanks for your efforts and sorry that i found not more time to test this.

@Lord-Grey
Copy link
Collaborator Author

@popy2k14 You can still do testing and provide feedback, even the PR was merged. 😃

@popy2k14
Copy link

@Lord-Grey i will, but dont know when i find time

@Lord-Grey Lord-Grey deleted the HomeAssistant branch September 30, 2024 20:06
@Kesp92
Copy link

Kesp92 commented Nov 14, 2024

Hi there @Lord-Grey
i just installed, Hyperion Ng in docker with the following file https://hub.docker.com/r/foorschtbar/hyperion .
But i got the Problem that the controlType homeassistant isn't shown any ideas?

@Lord-Grey
Copy link
Collaborator Author

You need to install the nightly build

@Pichuhoehle
Copy link

@Lord-Grey Is there any docker image, which has the nightly/dev builds?

@Lord-Grey
Copy link
Collaborator Author

Unfortunately, I do not know.

@Lord-Grey
Copy link
Collaborator Author

@flayzer Did you solve the issue with your Tapo lights?

@flayzer
Copy link

flayzer commented Dec 27, 2024

@Lord-Grey Yep, I managed to solve it! I just had to enable the advanced settings toggle. 😅

Thanks for all your hard work on this. It's working perfectly now. 🙌

@Lord-Grey
Copy link
Collaborator Author

@flayzer Could you do me a favour and test how the Tapo lights behave with different color/brightness combinations?
It looks like some devices cannot deal with brightness >0 and full black color (I see it on a Yeelight too).
Before doing a fix, I would like to get an idea how some lights behave.

Would you be able to run the following commands against your "overhead_light_bulb" bulb?
Replace TOKEN by the token you configured in Hyperion and update the IP address.
The first command is always sending full red to see the behaviour of the next command

  1. Full brightness / Black (Current Misbehaviour)

curl -X POST -H 'Authorization: Bearer TOKEN' -i 'http://192.168.x.x:8123/api/services/light/turn_on' --data '{"brightness":255,"entity_id":["light.overhead_light_bulb"],"rgb_color":[255,0,0]}'

curl -X POST -H 'Authorization: Bearer TOKEN' -i 'http://192.168.x.x:8123/api/services/light/turn_on' --data '{"brightness":255,"entity_id":["light.overhead_light_bulb"],"rgb_color":[0,0,0]}'

  1. Full brightness / a slight lighter Black

curl -X POST -H 'Authorization: Bearer TOKEN' -i 'http://192.168.x.x:8123/api/services/light/turn_on' --data '{"brightness":255,"entity_id":["light.overhead_light_bulb"],"rgb_color":[255,0,0]}'

curl -X POST -H 'Authorization: Bearer TOKEN' -i 'http://192.168.x.x:8123/api/services/light/turn_on' --data '{"brightness":255,"entity_id":["light.overhead_light_bulb"],"rgb_color":[1,1,1]}'

  1. No Brightness / Black

curl -X POST -H 'Authorization: Bearer TOKEN' -i 'http://192.168.x.x:8123/api/services/light/turn_on' --data '{"brightness":255,"entity_id":["light.overhead_light_bulb"],"rgb_color":[255,0,0]}'

curl -X POST -H 'Authorization: Bearer TOKEN' -i 'http://192.168.x.x:8123/api/services/light/turn_on' --data '{"entity_id":["light.overhead_light_bulb"],"rgb_color":[0,0,0]}'

  1. Brightness 0 / Black (it should switch of the light)

curl -X POST -H 'Authorization: Bearer TOKEN' -i 'http://192.168.x.x:8123/api/services/light/turn_on' --data '{"brightness":255,"entity_id":["light.overhead_light_bulb"],"rgb_color":[255,0,0]}'

curl -X POST -H 'Authorization: Bearer TOKEN' -i 'http://192.168.x.x:8123/api/services/light/turn_on' --data '{"brightness":0,"entity_id":["light.overhead_light_bulb"],"rgb_color":[0,0,0]}'

I think we should go for 4. but I would like to validate...

@flayzer
Copy link

flayzer commented Dec 27, 2024

Yeah, sure. Happy to help.

I noticed my bulb doesn't handle full black colour well, so I've opted for the "Switch off on black" option.

1. Full brightness / Black (Current Misbehaviour)

Behaviour: Bright white light
Attributes:

min_color_temp_kelvin: 2500
max_color_temp_kelvin: 6500
min_mireds: 153
max_mireds: 400
supported_color_modes:
  - color_temp
  - hs
effect: "off"
color_mode: hs
brightness: 255
color_temp_kelvin: null
color_temp: null
hs_color:
  - 0
  - 0
rgb_color:
  - 255
  - 255
  - 255

2. Full Brightness / Slightly Lighter Black

Behaviour: Bright white light
Attributes: Same as Test 1.

3. No Brightness / Black

Behaviour: Bright white light
Attributes: Same as Test 1.

4. Brightness / Black (Expected Behaviour: Switch Off)

Behaviour: Light switches off as expected.
State: off

Note: If the goal is to offer an alternative to turning the light off on black, perhaps allowing users to set a static RGB/brightness value (like a dim off-white) could be a viable solution. However, I’m unsure if this would be feasible to implement. I experimented with the backlight threshold options, but they didn’t quite achieve the effect I was aiming for.

Let me know if there’s anything else I can try.

@Lord-Grey
Copy link
Collaborator Author

Lord-Grey commented Dec 27, 2024

@flayzer Thanks for your very quick feedback!!!
I have created PR #1818 removing „Turn off on black“ in favour of setting brightness = 0 when Black. That better fits the HA Light Implementation.
The HA Integrations should better know, if they can turn off or display black… :)

Would be great, if you could test the PR.
See here how to do without affecting your current installation. If you are on Windows or osX, you can download an artifact from the latest PR build.

@flayzer
Copy link

flayzer commented Dec 27, 2024

@Lord-Grey I've tested the PR, and it's working as expected with my Tapo lights :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add Home Assistant support
9 participants