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

Light: changes required to work in current HA #134

Merged
merged 1 commit into from
Sep 22, 2024

Conversation

make-all
Copy link

  • remove delay parameter from get_controller call
  • don't await async_write_ha_state
  • call async_write_ha_state when state is changed to off

- remove `delay` parameter from get_controller call
- don't await async_write_ha_state
- call async_write_ha_state when state is changed to off
@make-all
Copy link
Author

These are changes on top of the maintainers changes to #132 to bring it up to date with this version of the integration.

With these changes, my previous set up (based on smartHomeHub#997) is again working on HA 2024.9

@litinoveweedle litinoveweedle merged commit 9636076 into litinoveweedle:lights Sep 22, 2024
2 checks passed
@litinoveweedle
Copy link
Owner

Hello, I was briefly checking light documentation and I have some doubts about how light.py is reflecting supported_color_modes. From the docs, it shall be list of supported modes (from ColorMode enum). But you are treating it as a scalar:

        if (
            CMD_COLORMODE_COLDER in self._commands
            and CMD_COLORMODE_WARMER in self._commands
        ):
            self._colortemp = self.max_color_temp_kelvin
            self._support_color_mode = ColorMode.COLOR_TEMP

        if CMD_NIGHTLIGHT in self._commands or (
            CMD_BRIGHTNESS_INCREASE in self._commands
            and CMD_BRIGHTNESS_DECREASE in self._commands
        ):
            self._brightness = 100
            self._support_brightness = True
            if self._support_color_mode == ColorMode.UNKNOWN:
                self._support_color_mode = ColorMode.BRIGHTNESS

This seems to be as wrong. Can you please explain?

@make-all
Copy link
Author

make-all commented Sep 22, 2024

Because there is no color bulb support, the supported color modes should be one of COLOR_TEMP, BRIGHTNESS or ONOFF.
Combinations of these do not appear to be valid (HA seems to have an assumption that if color temp is supported brightness is also supported).
Since there is only a possibility of one, I only track one, and it is turned into a list in the supported_color_modes implementation https://github.com/litinoveweedle/SmartIR/blob/lights/custom_components/smartir/light.py#L175

Probably this could be cleaned up to use the parent class's self._attr_supported_color_modes and supported_color_modes implementation (I wrote it 18 months ago before understanding fully the shortcuts available in the base entity classes).

@litinoveweedle
Copy link
Owner

you are correct, I checked te HA implementation and it says that those are mutually exclusive:

    ONOFF = "onoff"
    """Must be the only supported mode"""
    BRIGHTNESS = "brightness"
    """Must be the only supported mode"""
    COLOR_TEMP = "color_temp"

BTW: I think I saw some LED strips with IR remote, so there are probably some light with RGB support...

I will try to go trough rest of the code to be sure I understand it to be able to maintain it.

@litinoveweedle
Copy link
Owner

I just checked the docs (LIGHT.md) and it will need a bit of overhaul. Please check FAN.md for reference. Would you be please able to do it? Thank you.

@litinoveweedle
Copy link
Owner

I added light support into the READM.md. You do not need to provide LIGHT_CODES.md, as those pages are autogenerated on the merge with master.

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

Successfully merging this pull request may close these issues.

2 participants