Skip to content
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

Support for Light Component #76

Open
Baldhor opened this issue Dec 3, 2023 · 5 comments
Open

Support for Light Component #76

Baldhor opened this issue Dec 3, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@Baldhor
Copy link
Owner

Baldhor commented Dec 3, 2023

          In the meantime, I analyzed a little the attributs to implement to supports the light component fully.

Note: it goes much farther than your needs, but I will do it fully if possible.

https://esphome.io/components/light/index.html

transition_length: time! Require to implement a specific input format rule to allow to input seconds, hours, ... whatever
color_mode: dynamic list of values
brightness: percentage => slidder 0.0 to 1.0 (if mode is compatible)
color_brightness: percentage => slidder 0.0 to 1.0 (if mode is compatible)
red: percentage => slidder 0.0 to 1.0 (if mode is compatible)
green: percentage => slidder 0.0 to 1.0 (if mode is compatible)
bleu: percentage => slidder 0.0 to 1.0 (if mode is compatible)
white: percentage => slidder 0.0 to 1.0 (if mode is compatible)
color_temperature: float => slidder based on minMireds and Maxmireds
cold_white: percentage => slidder 0.0 to 1.0 (if mode is compatible)
warm_white: percentage => slidder 0.0 to 1.0 (if mode is compatible)
flash_length: time => refer to transition_length.
effect: dynamic list of values

Reminder: dynamic list of values is not supported by Homey, by default, only the context aware flow cards will be available.
=> Implementation of user specific list of value will be on user request for a beer!

Implementation of supportedColorMode is strange!
For exemple, the value 3 means ON_OFF && BRIGHTNESS.
=> https://www.esphome.io/api/color__mode_8h_source
I feel some mapping will be required ...

flash_length
This attribut require to send a color at the same time,.
A color can actually be any of the attributs red, blue, green, brigthness, ... and it depends of the color mode selected.
From Homey side, it's just impossible to implement such functionnality.
The only way would be to use a kind of script, or a specific format like: 2G1B1bri...
=> I will not be supported

low level api
Low level api use the legacySupported flag to authorize or not the functionnalities ...
legacy means legacy ... I feel it will create some issues!

    setBrightness(brightness) {
        if (!this.config.legacySupportsBrightness) throw new Error('brightness is not supported');
        this.command({ brightness });
    }

It should be based on the "selected mode":

ON_OFF: Only on/off control.
BRIGHTNESS: Only brightness control. Accepts brightness parameter.
WHITE: Single white channel only. Accepts brightness and white parameters.
COLOR_TEMPERATURE: Color-temperature controlled white channel. Accepts brightness and color_temperature parameters.
COLD_WARM_WHITE: Cold and warm white channels. Accepts brightness, color_temperature, cold_white and warm_white parameters.
RGB: RGB color channels. Accepts brightness, color_brightness, red, green and blue parameters.
RGB_WHITE: RGB color channels and a separate white channel. Accepts parameters from RGB and WHITE color modes.
RGB_COLOR_TEMPERATURE: RGB color channels and a separate color-temperature controlled white channel. Accepts parameters from RGB and COLOR_TEMPERATURE color modes.
RGB_COLD_WARM_WHITE: RGB color channels and two separate cold and warm white channels. Accepts parameters from RGB and COLD_WARM_WHITE color modes.

Originally posted by @Baldhor in #75 (comment)

@Baldhor Baldhor self-assigned this Dec 3, 2023
@Baldhor Baldhor added the enhancement New feature or request label Dec 3, 2023
@Baldhor
Copy link
Owner Author

Baldhor commented Dec 3, 2023

state and brightness are implement as part of #75

@Baldhor
Copy link
Owner Author

Baldhor commented Dec 4, 2023

Implementation steps:

  1. Implement color mode list
  2. change onoff and brightness to use color mode compatibilities (refer to first post), instead of hard coded rules (or legacy config flags)
  3. check how the UI component of homey will match with the capabilities
    image
  4. Implement missing attributs
  5. configure matching rules between native capabilities and homey capabilities

Out of scope:
transition_length and flash_length will be out of scope, I'm not going to implement it
The user can modify transition_length through the esphome web server, I cannot think of any use case the user would change it through a flow or so ...
flash_length has for purpose to make the light "blink" to a specific color for a short time, the user can implement the same function though esphome configuration and a button => go learn yaml (good luck lol)

@Baldhor
Copy link
Owner Author

Baldhor commented Dec 5, 2023

The color UI component of Homey use 4 capabilities:

  • light_hue, light_saturation and light_temperature: meaning it use HSV color values !?
  • light_mode : color or temperature => seems to impact the UI only, behind it, it's still HSV ...

ESPhome device use many different modes, so need to convert ... how fun ...
I found this lib: https://gka.github.io/chroma.js
=> seems to be of high quality

So on Homey side, we have 3 capabilities.
On ESPhome device side, we have "x" native capabilities ... x being defined by the color mode of the light component.

The solution I'm thinking about:

  • if the ESPhome device has a light component and if it's color mode support more than "onoff", the capability "color" will be proposed
  • The "color" capability will add light_hue, light_saturation and light_temperature capabilities to the virtual device
  • Conversion of color format will happen "on the fly" when reading/writing color from/to the device

Special behaviour already exist for templateCover (ie. one button swithing between open and close).
the new feature here is one capability which actually setup 3 homey capabilities, with complex conversion from those 3 capabilities values to x native capabilities ... big headheck ahead ...

@MrKonoreyich
Copy link

Hello,
As I see, you can change led`s color with homey`s color ring. Can you explain to how you configured it?

I have a small rgb led. It connected to esp32. Esp32 has esphome firmware

My rgb config:

light:
  - platform: rgb
    name: "RGB LED"
    red: output_red
    green: output_green
    blue: output_blue


output:
  - platform: ledc
    id: output_red
    pin: GPIO22
  - platform: ledc
    id: output_green
    pin: GPIO21
  - platform: ledc
    id: output_blue
    pin: GPIO23

When I trying to add led to homey, I don`t see color setting. Everything I can add is ON/OFF and brightness.
I saw your message, where you said to change some lines in color_mode.h (but what should I change?)

So, what should I do to make color ring appear? Can you explain it step by step please?

@Baldhor
Copy link
Owner Author

Baldhor commented Sep 1, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants