home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.54k stars 30.35k forks source link

Single channel MagicHome Controller not working #33899

Closed phcella closed 3 years ago

phcella commented 4 years ago

The problem

I have only white led Magic Home controller, and I can't control it through HA. When I try to turn it on, it blinks, freezes and doesn't turn on. I have already posted on comunity Link The other 2 RGB Magic Home controller are working correctly.

Environment

Problem-relevant configuration.yaml

light:
  - platform: flux_led
    devices:
      192.168.0.185:
        name: flux_pedro
        mode: "rgb"
      192.168.0.186:
        name: flux_bia
        mode: "rgb"
      192.168.0.183:
        name: flux_cortineiro
        mode: "w"

Traceback/Error logs

Additional information

teamsuperpanda commented 4 years ago

Can you control the LED strip from the Magic Home app? Might sound obvious but is the IP address correct? The third light '.0.183' has mode 'w' so the strip only has white leds on it? The magic home controllers are RGB or RGBW so what type are each of them?

Ybbet commented 4 years ago

The third light '.0.183' has mode 'w' so the strip only has white leds on it? The magic home controllers are RGB or RGBW so what type are each of them?

As said in the documentation, we could have 3 types: RGB, RGBW and W. Cf. https://www.home-assistant.io/integrations/flux_led/

It seems that the problem exists since version 0.97. #26779 Someone find a solution : https://community.home-assistant.io/t/flux-led-magiclight-dont-work-since-few-updated/145179/5 && https://gist.github.com/aptonic/5135800bdd558b7e24337bcb0f09531e

phcella commented 4 years ago

Can you control the LED strip from the Magic Home app?

It works perfectly

Might sound obvious but is the IP address correct?

The IP is correct, I fixed it on my router config

The third light '.0.183' has mode 'w' so the strip only has white leds on it? The magic home controllers are RGB or RGBW so what type are each of them?

My problem is only on the last led, "flux_cortineiro". The other are working perfectly. My controller is a single color controller like the image below.

And here are the video

      192.168.0.183:
        name: flux_cortineiro
        mode: "w"

image

annikovk commented 4 years ago

Do you have other flux_led devices which are offline at the moment you are trying to enable this one? If so, see #33275

phcella commented 4 years ago

Do you have other flux_led devices which are offline at the moment you are trying to enable this one? If so, see #33275

I saw yout issue too, and I got this error "WARNING (MainThread) [homeassistant.helpers.entity] Update of light.flux_cortineiro is taking over 10 seconds".

And I have 2 others RGB stripes and I have no errors. The problem is with thin White Controller

stale[bot] commented 4 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

phcella commented 4 years ago

I'm on 0.115.6 and my problem wasn't fixed on this last updates.

Ybbet commented 4 years ago

Hi, I confirm the problem.

GoNzCiD commented 3 years ago

I have the same MagicHome device and the same problem. From the Android MagicHome mobile application it works, but from HA not. I have also other MagicHome controllers that work but they are RGBW. Also the IP is correct.

Any solution @phcella? I'm in 0.117.2

phcella commented 3 years ago

I still have the problem only with the only white LED controller, with RGB controllers work perfectly. And I'm in 0.117.5.

Ediste commented 3 years ago

i have the same problem (HA: 0.117.5). Any solution?

GoNzCiD commented 3 years ago

I finally flash it with tasmota and works like a charm via mqtt...

phcella commented 3 years ago

i have the same problem (HA: 0.117.5). Any solution?

I'm on 2020.12.0, and I still have problem.

I finally flash it with tasmota and works like a charm via mqtt...

I should work without need to flash with Tasmota. I sometimes use the Magic Home app, and if I flash, it won't work anymore.

GoNzCiD commented 3 years ago

I should work without need to flash with Tasmota. I sometimes use the Magic Home app, and if I flash, it won't work anymore.

If you use Magic Home app, alternative firmware is not an option for you. I only use HA to manage it, and works quick and without fail. Yes the integration should work....

fvztdk commented 3 years ago

I'm on 0.118.5 and have the same problem with the same magic home as pointed above, other the color ones works without a problem (the ip is correct on my config and I can control the leds via magic home app and their integration with google home) *EDIT: updated to Home Assistant 2020.12.1 and the problem persist

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

phcella commented 3 years ago

The problem is not solved for me yet.

gitothy commented 3 years ago

Still an issue on 2021.3.4 for the "w" controller. RGB working fine.

@phcella a semi-workaround I'm using is to set the single channel controller to "rgb" mode instead of "w". Not exactly right but you can turn it on and off and do some of the brightness. Won't go past about 50% though and anything with colours screw it up so won't be good in a group. I did also test the "rgbw" mode and that does also give some control but is worse than rgb. Edit: also tested the ledenet protocol setting and that makes no difference.

phcella commented 3 years ago

@gitothy thanks for your tip, configuring it lake a "rgb" is better than "w", but it still have some delay to update de status and if you turn on / off fastly, it will not work correctly. But at least I can use it. Thanks!! And still waiting for correction o Hassio.

gitothy commented 3 years ago

There's also an almost complete solution I found today, it's a bit manual but resolves all of the issues here. https://github.com/CorneliousJD/flux_led

Tbh I'll probably flash the buggers to esphome rather than this code change but these are the options.

phcella commented 3 years ago

@gitothy Did you test it? Because it says it is for RGB Controllers. If it worked for you, i will do it here

gitothy commented 3 years ago

No haven't tested it yet and I don't want to go down that road.

Another 'non-flashing' solution is here. Looks good but you need to have Homebridge set up. https://community.home-assistant.io/t/flux-led-magiclight-dont-work-since-few-updated/145179/66

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

gitothy commented 3 years ago

@phcella is this solved in the latest version of HomeAssistant for you?

phcella commented 3 years ago

@gitothy I'm on 2021.6.6 and the problem continues. Do you know If I flash with Tasmota, I can flash with the original firmware after if I want?

gitothy commented 3 years ago

Do you know If I flash with Tasmota, I can flash with the original firmware after if I want?

Hmm not 100% sure. I don't know if these boards use the ESP8266/ESP32 so not sure if you'll be able to flash Tasmota?

aheath70 commented 3 years ago

I just bought the exact same single color controller and I have spent the last 2 days trying to work out what is going on. I eventually worked out that with the flux_led python library, monochrome controller brightness is actually set by the value of the Red color, not by the brightness. I figured this out by installing the python library on a Linux box, and just trying different commands. So, here is a new light.py file that is working flawlessly for me with my single monochrome LED controller. You may want to test it if you have RGB or RGBW controllers - I don't have any so couldn't test.

"""Support for Flux lights."""
import logging
import random
import socket

from flux_led import BulbScanner, WifiLedBulb
import voluptuous as vol

from homeassistant.components.light import (
    ATTR_BRIGHTNESS,
    ATTR_COLOR_TEMP,
    ATTR_EFFECT,
    ATTR_HS_COLOR,
    ATTR_WHITE_VALUE,
    EFFECT_COLORLOOP,
    EFFECT_RANDOM,
    PLATFORM_SCHEMA,
    SUPPORT_BRIGHTNESS,
    SUPPORT_COLOR,
    SUPPORT_COLOR_TEMP,
    SUPPORT_EFFECT,
    SUPPORT_WHITE_VALUE,
    LightEntity,
)
from homeassistant.const import ATTR_MODE, CONF_DEVICES, CONF_NAME, CONF_PROTOCOL
import homeassistant.helpers.config_validation as cv
import homeassistant.util.color as color_util

_LOGGER = logging.getLogger(__name__)

CONF_AUTOMATIC_ADD = "automatic_add"
CONF_CUSTOM_EFFECT = "custom_effect"
CONF_COLORS = "colors"
CONF_SPEED_PCT = "speed_pct"
CONF_TRANSITION = "transition"

DOMAIN = "flux_led"

SUPPORT_FLUX_LED = SUPPORT_BRIGHTNESS | SUPPORT_EFFECT | SUPPORT_COLOR

MODE_RGB = "rgb"
MODE_RGBW = "rgbw"

# This mode enables white value to be controlled by brightness.
# RGB value is ignored when this mode is specified.
MODE_WHITE = "w"

# Constant color temp values for 2 flux_led special modes
# Warm-white and Cool-white modes
COLOR_TEMP_WARM_VS_COLD_WHITE_CUT_OFF = 285

# List of supported effects which aren't already declared in LIGHT
EFFECT_RED_FADE = "red_fade"
EFFECT_GREEN_FADE = "green_fade"
EFFECT_BLUE_FADE = "blue_fade"
EFFECT_YELLOW_FADE = "yellow_fade"
EFFECT_CYAN_FADE = "cyan_fade"
EFFECT_PURPLE_FADE = "purple_fade"
EFFECT_WHITE_FADE = "white_fade"
EFFECT_RED_GREEN_CROSS_FADE = "rg_cross_fade"
EFFECT_RED_BLUE_CROSS_FADE = "rb_cross_fade"
EFFECT_GREEN_BLUE_CROSS_FADE = "gb_cross_fade"
EFFECT_COLORSTROBE = "colorstrobe"
EFFECT_RED_STROBE = "red_strobe"
EFFECT_GREEN_STROBE = "green_strobe"
EFFECT_BLUE_STROBE = "blue_strobe"
EFFECT_YELLOW_STROBE = "yellow_strobe"
EFFECT_CYAN_STROBE = "cyan_strobe"
EFFECT_PURPLE_STROBE = "purple_strobe"
EFFECT_WHITE_STROBE = "white_strobe"
EFFECT_COLORJUMP = "colorjump"
EFFECT_CUSTOM = "custom"

EFFECT_MAP = {
    EFFECT_COLORLOOP: 0x25,
    EFFECT_RED_FADE: 0x26,
    EFFECT_GREEN_FADE: 0x27,
    EFFECT_BLUE_FADE: 0x28,
    EFFECT_YELLOW_FADE: 0x29,
    EFFECT_CYAN_FADE: 0x2A,
    EFFECT_PURPLE_FADE: 0x2B,
    EFFECT_WHITE_FADE: 0x2C,
    EFFECT_RED_GREEN_CROSS_FADE: 0x2D,
    EFFECT_RED_BLUE_CROSS_FADE: 0x2E,
    EFFECT_GREEN_BLUE_CROSS_FADE: 0x2F,
    EFFECT_COLORSTROBE: 0x30,
    EFFECT_RED_STROBE: 0x31,
    EFFECT_GREEN_STROBE: 0x32,
    EFFECT_BLUE_STROBE: 0x33,
    EFFECT_YELLOW_STROBE: 0x34,
    EFFECT_CYAN_STROBE: 0x35,
    EFFECT_PURPLE_STROBE: 0x36,
    EFFECT_WHITE_STROBE: 0x37,
    EFFECT_COLORJUMP: 0x38,
}
EFFECT_CUSTOM_CODE = 0x60

TRANSITION_GRADUAL = "gradual"
TRANSITION_JUMP = "jump"
TRANSITION_STROBE = "strobe"

FLUX_EFFECT_LIST = sorted(list(EFFECT_MAP)) + [EFFECT_RANDOM]

CUSTOM_EFFECT_SCHEMA = vol.Schema(
    {
        vol.Required(CONF_COLORS): vol.All(
            cv.ensure_list,
            vol.Length(min=1, max=16),
            [
                vol.All(
                    vol.ExactSequence((cv.byte, cv.byte, cv.byte)), vol.Coerce(tuple)
                )
            ],
        ),
        vol.Optional(CONF_SPEED_PCT, default=50): vol.All(
            vol.Range(min=0, max=100), vol.Coerce(int)
        ),
        vol.Optional(CONF_TRANSITION, default=TRANSITION_GRADUAL): vol.All(
            cv.string, vol.In([TRANSITION_GRADUAL, TRANSITION_JUMP, TRANSITION_STROBE])
        ),
    }
)

DEVICE_SCHEMA = vol.Schema(
    {
        vol.Optional(CONF_NAME): cv.string,
        vol.Optional(ATTR_MODE, default=MODE_RGBW): vol.All(
            cv.string, vol.In([MODE_RGBW, MODE_RGB, MODE_WHITE])
        ),
        vol.Optional(CONF_PROTOCOL): vol.All(cv.string, vol.In(["ledenet"])),
        vol.Optional(CONF_CUSTOM_EFFECT): CUSTOM_EFFECT_SCHEMA,
    }
)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {
        vol.Optional(CONF_DEVICES, default={}): {cv.string: DEVICE_SCHEMA},
        vol.Optional(CONF_AUTOMATIC_ADD, default=False): cv.boolean,
    }
)

def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Flux lights."""
    lights = []
    light_ips = []

    for ipaddr, device_config in config.get(CONF_DEVICES, {}).items():
        device = {}
        device["name"] = device_config[CONF_NAME]
        device["ipaddr"] = ipaddr
        device[CONF_PROTOCOL] = device_config.get(CONF_PROTOCOL)
        device[ATTR_MODE] = device_config[ATTR_MODE]
        device[CONF_CUSTOM_EFFECT] = device_config.get(CONF_CUSTOM_EFFECT)
        light = FluxLight(device)
        lights.append(light)
        light_ips.append(ipaddr)

    if not config.get(CONF_AUTOMATIC_ADD, False):
        add_entities(lights, True)
        return

    # Find the bulbs on the LAN
    scanner = BulbScanner()
    scanner.scan(timeout=10)
    for device in scanner.getBulbInfo():
        ipaddr = device["ipaddr"]
        if ipaddr in light_ips:
            continue
        device["name"] = "{} {}".format(device["id"], ipaddr)
        device[ATTR_MODE] = None
        device[CONF_PROTOCOL] = None
        device[CONF_CUSTOM_EFFECT] = None
        light = FluxLight(device)
        lights.append(light)

    add_entities(lights, True)

class FluxLight(LightEntity):
    """Representation of a Flux light."""

    def __init__(self, device):
        """Initialize the light."""
        self._name = device["name"]
        self._ipaddr = device["ipaddr"]
        self._protocol = device[CONF_PROTOCOL]
        self._mode = device[ATTR_MODE]
        self._custom_effect = device[CONF_CUSTOM_EFFECT]
        self._bulb = None
        self._error_reported = False

    def _connect(self):
        """Connect to Flux light."""

        self._bulb = WifiLedBulb(self._ipaddr, timeout=5)
        if self._protocol:
            self._bulb.setProtocol(self._protocol)

        # After bulb object is created the status is updated. We can
        # now set the correct mode if it was not explicitly defined.
        if not self._mode:
            if self._bulb.rgbwcapable:
                self._mode = MODE_RGBW
            else:
                self._mode = MODE_RGB

    def _disconnect(self):
        """Disconnect from Flux light."""
        self._bulb = None

    @property
    def available(self) -> bool:
        """Return True if entity is available."""
        return self._bulb is not None

    @property
    def name(self):
        """Return the name of the device if any."""
        return self._name

    @property
    def is_on(self):
        """Return true if device is on."""
        return self._bulb.isOn()

    @property
    def brightness(self):
        """Return the brightness of this light between 0..255."""
        # if self._mode == MODE_WHITE:
        #     return self.white_value

        return self._bulb.brightness

    @property
    def hs_color(self):
        """Return the color property."""
        return color_util.color_RGB_to_hs(*self._bulb.getRgb())

    @property
    def supported_features(self):
        """Flag supported features."""
        if self._mode == MODE_RGBW:
            return SUPPORT_FLUX_LED | SUPPORT_WHITE_VALUE | SUPPORT_COLOR_TEMP

        if self._mode == MODE_WHITE:
            return SUPPORT_BRIGHTNESS

        return SUPPORT_FLUX_LED

    @property
    def white_value(self):
        """Return the white value of this light between 0..255."""
        return self._bulb.getRgbw()[3]

    @property
    def effect_list(self):
        """Return the list of supported effects."""
        if self._custom_effect:
            return FLUX_EFFECT_LIST + [EFFECT_CUSTOM]

        return FLUX_EFFECT_LIST

    @property
    def effect(self):
        """Return the current effect."""
        current_mode = self._bulb.raw_state[3]

        if current_mode == EFFECT_CUSTOM_CODE:
            return EFFECT_CUSTOM

        for effect, code in EFFECT_MAP.items():
            if current_mode == code:
                return effect

        return None

    def turn_on(self, **kwargs):
        """Turn the specified or all lights on."""
#        if not self.is_on:
#            self._bulb.turnOn()

        hs_color = kwargs.get(ATTR_HS_COLOR)

        if hs_color:
            rgb = color_util.color_hs_to_RGB(*hs_color)
        else:
            rgb = None

        brightness = kwargs.get(ATTR_BRIGHTNESS)
        effect = kwargs.get(ATTR_EFFECT)
        white = kwargs.get(ATTR_WHITE_VALUE)
        color_temp = kwargs.get(ATTR_COLOR_TEMP)

        # handle special modes
        if color_temp is not None:
            if brightness is None:
                brightness = self.brightness
            if color_temp > COLOR_TEMP_WARM_VS_COLD_WHITE_CUT_OFF:
                self._bulb.setRgbw(w=brightness)
            else:
                self._bulb.setRgbw(w2=brightness)
            return

        # Show warning if effect set with rgb, brightness, or white level
        if effect and (brightness or white or rgb):
            _LOGGER.warning(
                "RGB, brightness and white level are ignored when"
                " an effect is specified for a flux bulb"
            )

        # Random color effect
        if effect == EFFECT_RANDOM:
            self._bulb.setRgb(
                random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)
            )
            return

        if effect == EFFECT_CUSTOM:
            if self._custom_effect:
                self._bulb.setCustomPattern(
                    self._custom_effect[CONF_COLORS],
                    self._custom_effect[CONF_SPEED_PCT],
                    self._custom_effect[CONF_TRANSITION],
                )
            return

        # Effect selection
        if effect in EFFECT_MAP:
            self._bulb.setPresetPattern(EFFECT_MAP[effect], 50)
            return

        # Preserve current brightness on color/white level change
        if brightness is None:
            brightness = self.brightness

        # If these are 0 then bulb.isOn will return false, not what we want
        if hs_color is None or (hs_color[0] == 0 and hs_color[1] == 0):
            hs_color = (1, 1, 1)

        if brightness is None or brightness == 0:
            brightness = 100

        # Preserve color on brightness/white level change
        if rgb is None:
            rgb = self._bulb.getRgb()

        if white is None and self._mode == MODE_RGBW:
            white = self.white_value

        # handle W only mode (use red luminence and brightness instead of white value)
        if self._mode == MODE_WHITE:
            self._bulb.setRgbw(r=brightness, g=0, b=0, w=0, brightness=brightness)

        # handle RGBW mode
        elif self._mode == MODE_RGBW:
            self._bulb.setRgbw(*tuple(rgb), w=white, brightness=brightness)

        # handle RGB mode
        else:
            self._bulb.setRgb(*tuple(rgb), brightness=brightness)

    def turn_off(self, **kwargs):
        """Turn the specified or all lights off."""
        self._bulb.turnOff()

    def update(self):
        """Synchronize state with bulb."""
        if not self.available:
            try:
                self._connect()
                self._error_reported = False
            except socket.error:
                self._disconnect()
                if not self._error_reported:
                    _LOGGER.warning(
                        "Failed to connect to bulb %s, %s", self._ipaddr, self._name
                    )
                    self._error_reported = True
                return

        self._bulb.update_state(retry=2)
aheath70 commented 3 years ago

I just looked, and there is no code owner for the flux_led component in Home Assistant.

@icemanch are you the best person to look at this?

icemanch commented 3 years ago

I just looked, and there is no code owner for the flux_led component in Home Assistant.

@icemanch are you the best person to look at this?

I think there's actually three or four people looking at it. I've been gone but, I"m jumping back in and getting caught up. If this is still an issue I'll take a look at it.

aheath70 commented 3 years ago

I haven't tested it recently, as I am running the code I pasted above, installed under the "custom_components" directory. It is working perfectly for my single colour controller. I don't know whether the changes that I made would break RGB or RGBW controllers, as I have neither.

It was certainly still a problem under 2021.6 and as far as I can tell from the release notes, there have been no changes to the flux_led component in the 2 versions since.

icemanch commented 3 years ago

I haven't tested it recently, as I am running the code I pasted above, installed under the "custom_components" directory. It is working perfectly for my single colour controller. I don't know whether the changes that I made would break RGB or RGBW controllers, as I have neither.

It was certainly still a problem under 2021.6 and as far as I can tell from the release notes, there have been no changes to the flux_led component in the 2 versions since.

I know which problem you're talking about now. I've been trying to get code finished to fix it for a few months now but, I had to work on a different project for the last two months so nothing moved. The component is almost completely re-written (there were other bugs and updates it needed) but, I need to figure out where I left off and test everything again so that it can get published. :)

bdraco commented 3 years ago

Do you know of a vendor that will ship the US that sells these controllers?

Can you post the flux_led info lines for the device? Example:

% flux_led -i 192.168.107.91
Unknown ID [192.168.107.91] OFF  [Warm White: 0% raw state: 129,53,36,97,1,5,88,178,0,0,7,0,240,66,]

We can add it to the database so its detected properly in the next release https://github.com/Danielhiversen/flux_led/blob/master/flux_led/models_db.py

Thanks

bdraco commented 3 years ago

I found one here https://www.aliexpress.com/item/1005002275661910.html?spm=a2g0s.9042311.pcrcomd.5.27424c4d8HC1iy&gps-id=pcOrderList&scm=1007.30114.213637.0&scm_id=1007.30114.213637.0&scm-url=1007.30114.213637.0&pvid=455b3830-7a79-41d8-bf3c-8ca9725d4558&_t=gps-id:pcOrderList,scm-url:1007.30114.213637.0,pvid:455b3830-7a79-41d8-bf3c-8ca9725d4558,tpp_buckets:668%232846%238115%232000&&pdp_ext_f=%7B%22sceneId%22:%2220114%22,%22sku_id%22:%2212000019872173906%22%7D

Looks like it will show up in a month or so

aheath70 commented 3 years ago

When state of light is on and at full brightness:

Unknown ID [192.168.0.196] ON  [Color: (255, 0, 0) Brightness: 255 raw state: 129,65,35,97,65,1,255,0,0,0,2,0,0,137,]

When state of light is on and at 50% brightness:

Unknown ID [192.168.0.196] ON  [Color: (128, 0, 0) Brightness: 128 raw state: 129,65,35,97,65,1,128,0,0,0,2,0,0,10,]

When state of light is on and at 10% brightness:

Unknown ID [192.168.0.196] ON  [Color: (26, 0, 0) Brightness: 26 raw state: 129,65,35,97,65,1,26,0,0,0,2,0,0,164,]

When state of light is off and its last state was full brightness:

Unknown ID [192.168.0.196] OFF  [Color: (255, 0, 0) Brightness: 255 raw state: 129,65,36,97,65,1,255,0,0,0,2,0,0,138,]

When state of light is off and its last state was 50% brightness:

Unknown ID [192.168.0.196] OFF  [Color: (128, 0, 0) Brightness: 128 raw state: 129,65,36,97,65,1,128,0,0,0,2,0,0,11,]

When state of light is off and its last state was 10% brightness:

Unknown ID [192.168.0.196] OFF  [Color: (26, 0, 0) Brightness: 26 raw state: 129,65,36,97,65,1,26,0,0,0,2,0,0,165,]
bdraco commented 3 years ago

Thanks. So it uses the 'RED' channel for everything

aheath70 commented 3 years ago

Yes, it uses the red channel to set the brightness. My custom component that I have written (code above) keeps the brightness attribute the same as the red channel, so it reports the brightness through home assistance correctly as well.

bdraco commented 3 years ago

If you go into the Magic Home Pro app and long press on the device (iOS) do you can an option to change device type?

aheath70 commented 3 years ago

If you go into the Magic Home Pro app and long press on the device (iOS) do you can an option to change device type?

No. I get options to "Add To Group" or "Rename".

FYI, I just ran the same "flux_led -i" commands after adjusting the brightness and switching on and off using the Magic Home app, and it resulted in the same outputs as above with the red channel and brightness kept in sync by the Magic Home app.

bdraco commented 3 years ago

That's unfortunate that it maps to the red channel

We have to support channel remapping, I started a PR here https://github.com/Danielhiversen/flux_led/pull/116

There's a lot of work going on with this integration at the moment so the pr will have to wait until merges calm down a bit because of merge conflicts

bdraco commented 3 years ago

Found this one https://www.amazon.com/gp/product/B07JC7YR9J/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1 which doesn't have a 5 week delivery time. 👍

bdraco commented 3 years ago

Can someone test the remapping support with ?

https://github.com/home-assistant/core/pull/57353 and https://github.com/Danielhiversen/flux_led/pull/116

bdraco commented 3 years ago

device showed up.

57353 fixed the brightness reporting, but not the setting.

This needs a bit more work to remap the channel before set_levels

aheath70 commented 3 years ago

Agreed. I just downloaded the new component about 10 mins ago and was testing, and it wasn't working properly. Reverted back to my custom component in the meantime.

bdraco commented 3 years ago

Turns out a little more work was needed to map where we set the levels as well

Confirmed working with

https://github.com/home-assistant/core/pull/57458 and https://github.com/Danielhiversen/flux_led/pull/124

@aheath70 Can you give it another go?

aheath70 commented 3 years ago

@bdraco - My Github skills are pretty rudimentary, and I don't know how to merge the pull requests and get done what I need to get done in order to test. If it is straightforward, if you can walk me through what I need to do, then I am more than happy to test. Sorry!

icemanch commented 3 years ago

@bdraco - My Github skills are pretty rudimentary, and I don't know how to merge the pull requests and get done what I need to get done in order to test. If it is straightforward, if you can walk me through what I need to do, then I am more than happy to test. Sorry!

I'll see if I can walk you through it. You need to get the component and the latest flux_led. Just as a warning I'm going to walk you through how to do it but, if you're doing it on a production system you may mess it up. I've done it several times and not had a problem but, I"m just trowing it out there as a just in case. Make sure you backup.

Get the component first. These commands need to be run inside your home assistant container.

  1. Go to an empty folder that you want to download into.
  2. Run "Git Clone https://github.com/bdraco/home-assistant"
  3. change directory in "home-assistant"
  4. Run "Git Switch fix_single_channel_flux"
  5. Run "Git Fetch"
  6. change directory to "homeassistant/componets"
  7. Run "cp -r flux_led /usr/src/homeassistant/homeassistant/componets/"
  8. change directory to "/usr/src/homeassistant/homeassistant"
  9. Run "python3 -m script.hassfest"

Restart home assistant.

Now you need to get the latest flux_led api. These commands need to be run inside your home assistant container.

  1. Go to an empty folder
  2. Run "Git Clone https://github.com/Danielhiversen/flux_led"
  3. change directory into "flux_led"
  4. Run "Git Fetch"
  5. Run "python3 -m pip show flux_led" ***This will show you were flux_led lives. Should be something like /usr/local/lib/python3.9/site-packages
  6. You need to copy the python files to the location given above. So if it matches you would run "cp -r flux_led /usr/local/lib/python3.9/site-packages/"

Restart home assistant again.

Everything should be on the latest and you can begin testing to see if it works.

There might be an easier way but, this is how I do it. I'm rather new to the process as well but, it's worked everytime so far.

aheath70 commented 3 years ago

OK. I only have a production system. I might see if I can create a new test system and work on it, but it may be a little while before I get that done - work is smashing me at the moment.

bdraco commented 3 years ago

It can also be installed as a custom component once we do a new release of flux_led. I'll post instructions once that is done

aheath70 commented 3 years ago

It can also be installed as a custom component once we do a new release of flux_led. I'll post instructions once that is done

I think I would definitely be more comfortable installing it as a custom component.

bdraco commented 3 years ago

Testing steps:

mkdir -p /config/custom_components
cd /config/custom_components
git clone https://github.com/bdraco/flux_led_custom flux_led

Restart

To revert to the version in core, delete /config/custom_components/flux_led