AlexxIT / SonoffLAN

Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant
https://github.com/AlexxIT/Blog
MIT License
2.58k stars 403 forks source link

L3-5M-P control issues #1394

Open Oktandrew opened 2 months ago

Oktandrew commented 2 months ago

L3-5M-P behaves weirdly, when using custom colors, you can control the RGB color, or the brightness, but not both. Setting the RGB color sets the brightness to 100% Setting the brightness sets the RGB to a seemingly arbitrary value of, loosely, ~(80,225,255) Control via the native app works fine.

AlexxIT commented 2 months ago

https://github.com/AlexxIT/SonoffLAN?tab=readme-ov-file#issues

Oktandrew commented 2 months ago

Sorry for the low-effort bug report. Here are some diagnostic data: Online devices:

`Version | 3.7.2 (eb0a208)`
`Cloud devices online | 7 / 8`
`Local devices online | 5 / 5`

(The 1 offline is normal, its just my nightstand which I often manually switch off)

Warning and errors on logs: None related to SonoffLAN Device diagonstics: sonoff-led.json

Device debug experiments: 1) Manually trying to set color Red, RGB=(255,0,0), brightness slider is around 50%. This results in LED becoming Red RGB=(255,0,0), but at 100% brightness:

`2024-05-01 14:36:39 [D] 10017bd6e3 => Cloud4 | {'mode': 1, 'colorR': 255, 'colorG': 0, 'colorB': 0, 'light_type': 1} | 1714563399550`
`2024-05-01 14:36:39 [D] 10017bd6e3 => Cloud4 | DDoS | 1714563399651`
`2024-05-01 14:36:39 [D] 10017bd6e3 <= Cloud3 | {'version': 8, 'init': 1, 'fwVersion': '1000.2.1060', 'switch': 'on', 'lineSequence': {'1': 'g', '2': 'r', '3': 'b'}, 'icNumber': 150, 'icType': 0, 'NO_SEND_TO_APP': 0, 'timeZone': 3, 'colorR': 255, 'colorG': 0, 'colorB': 0, 'mode': 1, 'bright': 46, 'speed07': 50, 'bright07': 100, 'light_type': 1, 'speed08': 50, 'bright08': 100, 'rhythmMode': 2, 'rhythmSensitive': 100, 'speed29': 100, 'bright29': 100, 'speed41': 51, 'bright41': 100, 'speed13': 50, 'bright13': 100, 'speed16': 100, 'bright16': 100, 'speed22': 100, 'bright22': 100, 'speed23': 100, 'bright23': 100, 'speed24': 100, 'bright24': 100, 'speed25': 50, 'bright25': 100, 'speed45': 100, 'bright45': 100, 'speed35': 50, 'bright35': 100, 'speed36': 50, 'bright36': 100, 'speed37': 50, 'bright37': 100, 'speed39': 50, 'bright39': 100, 'speed10': 76, 'bright10': 100, 'speed18': 50, 'speed17': 50, 'colorTemp': 50, 'bright18': 100, 'speed47': 50, 'bright47': 100, 'speed48': 50, 'bright48': 100, 'speed49': 50, 'bright49': 100, 'speed50': 50, 'bright50': 100, 'speed43': 50, 'bright43': 100, 'speed46': 50, 'bright46': 100, 'speed38': 50, 'bright38': 100, 'speed31': 50, 'bright31': 100, 'speed32': 100, 'bright32': 100, 'speed28': 50, 'bright28': 100, 'speed11': 50, 'bright11': 100, 'speed21': 50, 'bright21': 100, 'speed14': 50, 'bright14': 100, 'speed15': 50, 'bright15': 100, 'speed19': 50, 'bright19': 100} | 1714563399651`

2) One moment later, trying to move the brightness slider further down, to dim (28%). This results in LED becoming Green-ish Blue at approximately RGB=(80,225,255), but the brightness is correctly set at 28%

`2024-05-01 14:36:48 [D] 10017bd6e3 => Cloud4 | {'mode': 1, 'bright': 28} | 1714563408985`
`2024-05-01 14:36:49 [D] 10017bd6e3 => Cloud4 | DDoS | 1714563409087`
`2024-05-01 14:36:49 [D] 10017bd6e3 <= Cloud3 | {'version': 8, 'init': 1, 'fwVersion': '1000.2.1060', 'switch': 'on', 'lineSequence': {'1': 'g', '2': 'r', '3': 'b'}, 'icNumber': 150, 'icType': 0, 'NO_SEND_TO_APP': 0, 'timeZone': 3, 'colorR': 255, 'colorG': 0, 'colorB': 0, 'mode': 1, 'bright': 28, 'speed07': 50, 'bright07': 100, 'light_type': 1, 'speed08': 50, 'bright08': 100, 'rhythmMode': 2, 'rhythmSensitive': 100, 'speed29': 100, 'bright29': 100, 'speed41': 51, 'bright41': 100, 'speed13': 50, 'bright13': 100, 'speed16': 100, 'bright16': 100, 'speed22': 100, 'bright22': 100, 'speed23': 100, 'bright23': 100, 'speed24': 100, 'bright24': 100, 'speed25': 50, 'bright25': 100, 'speed45': 100, 'bright45': 100, 'speed35': 50, 'bright35': 100, 'speed36': 50, 'bright36': 100, 'speed37': 50, 'bright37': 100, 'speed39': 50, 'bright39': 100, 'speed10': 76, 'bright10': 100, 'speed18': 50, 'speed17': 50, 'colorTemp': 50, 'bright18': 100, 'speed47': 50, 'bright47': 100, 'speed48': 50, 'bright48': 100, 'speed49': 50, 'bright49': 100, 'speed50': 50, 'bright50': 100, 'speed43': 50, 'bright43': 100, 'speed46': 50, 'bright46': 100, 'speed38': 50, 'bright38': 100, 'speed31': 50, 'bright31': 100, 'speed32': 100, 'bright32': 100, 'speed28': 50, 'bright28': 100, 'speed11': 50, 'bright11': 100, 'speed21': 50, 'bright21': 100, 'speed14': 50, 'bright14': 100, 'speed15': 50, 'bright15': 100, 'speed19': 50, 'bright19': 100} | 1714563409087`

3) (This is sort-of unrelated with the issue, but it is still a 'bug') When trying to create a Scene that sets the LED to RGB=(1,9,255), and brightness 46%, there is no way to disable the "Effect" menu, meaning it automatically (and without ever being clicked or interacted with), selected the (default?) value of "Dynamic Music", which in turn makes the LED become music-activated.

`2024-05-01 14:37:03 [D] 10017bd6e3 => Cloud4 | {'switch': 'on', 'mode': 4, 'rhythmMode': 2, 'rhythmSensitive': 100, 'bright': 46, 'light_type': 1, 'colorR': 1, 'colorG': 9, 'colorB': 255} | 1714563423060`
`2024-05-01 14:37:03 [D] 10017bd6e3 => Cloud4 | DDoS | 1714563423160`
`2024-05-01 14:37:03 [D] 10017bd6e3 <= Cloud3 | {'version': 8, 'init': 1, 'fwVersion': '1000.2.1060', 'switch': 'on', 'lineSequence': {'1': 'g', '2': 'r', '3': 'b'}, 'icNumber': 150, 'icType': 0, 'NO_SEND_TO_APP': 0, 'timeZone': 3, 'colorR': 1, 'colorG': 9, 'colorB': 255, 'mode': 4, 'bright': 46, 'speed07': 50, 'bright07': 100, 'light_type': 1, 'speed08': 50, 'bright08': 100, 'rhythmMode': 2, 'rhythmSensitive': 100, 'speed29': 100, 'bright29': 100, 'speed41': 51, 'bright41': 100, 'speed13': 50, 'bright13': 100, 'speed16': 100, 'bright16': 100, 'speed22': 100, 'bright22': 100, 'speed23': 100, 'bright23': 100, 'speed24': 100, 'bright24': 100, 'speed25': 50, 'bright25': 100, 'speed45': 100, 'bright45': 100, 'speed35': 50, 'bright35': 100, 'speed36': 50, 'bright36': 100, 'speed37': 50, 'bright37': 100, 'speed39': 50, 'bright39': 100, 'speed10': 76, 'bright10': 100, 'speed18': 50, 'speed17': 50, 'colorTemp': 50, 'bright18': 100, 'speed47': 50, 'bright47': 100, 'speed48': 50, 'bright48': 100, 'speed49': 50, 'bright49': 100, 'speed50': 50, 'bright50': 100, 'speed43': 50, 'bright43': 100, 'speed46': 50, 'bright46': 100, 'speed38': 50, 'bright38': 100, 'speed31': 50, 'bright31': 100, 'speed32': 100, 'bright32': 100, 'speed28': 50, 'bright28': 100, 'speed11': 50, 'bright11': 100, 'speed21': 50, 'bright21': 100, 'speed14': 50, 'bright14': 100, 'speed15': 50, 'bright15': 100, 'speed19': 50, 'bright19': 100} | 1714563423160`

My understanding of the problem, is that the integration doesn't send a full command, containing both the RGB value and the brightness, and instead sends only the value that changed. Sonoff's servers then probably automatically fill in the 'gaps', setting 100% if the brightness is missing and ~(80,225,255) if the color is missing.

If the LEDs are set to a preset from a Scene, SonoffLAN sends a full command, containing both RGB AND brightness, but it also includes the "Effect", which you cannot disable, because a "None" or "Disabled" option is missing from the drop-down menu for "Effects", meaning that you're actually forced to select one, (which you shouldn't, effects are optional, since they're a different mode, and they override any RGB/brightness set by the user anyway).

AlexxIT commented 2 months ago

I can't confirm your words. I don't have this bulb. But tests say than integration sends brightness+rgb without any problems: https://github.com/AlexxIT/SonoffLAN/commit/eea500dd20046e7c01d93ef7827174378bcfb795

Oktandrew commented 2 months ago

Hello, the integration indeed seems to work fine. I think the problem comes from what the UI is asking the integration to do. I dug a little deeper and I tried calling sonoff.send_command like so:

service: sonoff.send_command
data: 
  device: 10017bd6e3
  switch: 'on'
  mode: 1
  colorR: 255
  colorG: 0
  colorB: 0
  bright: 10

And it worked! The LEDs indeed turned Red and at 10% brightness.

Then I tried to set just the brightness with:

service: sonoff.send_command
data: 
  device: 10017bd6e3
  switch: 'on'
  mode: 1
  bright: 11

and the LEDs turned into RGB(80,225,255) at 11% brightness

exactly after that, I ran:

service: sonoff.send_command
data: 
  device: 10017bd6e3
  switch: 'on'
  mode: 1
  colorR: 255
  colorG: 0
  colorB: 0

which is missing it's "bright" value. and the LEDs turned Red but at full brightness!

Curiously, I tried the same experiment with my other LED controller by Sonoff, "L2", which is a standalone RGB strip controller, and it doesn't behave that way, instead it 'remembers' the values of RGB and brightness, and doesn't reset them every time a new command is ordered. But L3-5M-P required all 4 values (bright,colorR,colorG,colorB) to be present, otherwise it would mess up.

I didn't entirely understand the test you conducted earlier, but by sending await_(light.async_turn_on(brightness=128, rgb_color=(255, 0, 0))) the integration does something which is (as I understand), impossible to do currently with the UI (unless triggered by a scene preset, which has that other glitch I mentioned earlier, making it only usable if you want to use an "effect"), but quite similar, if not identical, to the commands I sent using the Developer tools.

Also curiously, it doesn't seem that anyone else has this issue. It's very hard if impossible to miss, and it would have been caught during development...

Thanks for looking into this.