SonoffLAN: B02 and B05 color temperature ranges wrong
Hello @AlexxIT I just bought two B05-BL-A60 rgb light bulbs and I had some problems making them work with color temperature slider on HA. I think the issue can be related to #766 (already closed).
I’m using version 3.0.5 of your repository.
Looking at sonoff SDK reference https://sonoff.tech/sonoff-diy-developer-documentation-b02-bl-b05-bl-http-api/
It seems that the “CT” parameter must have a range of [0,100] but in your code the conversion from mireds is done like [153,500] -> [0,255]. So whenever you set the color with ltype=white the range is wrong and any value past 100 gives an error in integration.
2022-07-06 11:15:04 WARNING (MainThread) [custom_components.sonoff.core.ewelink.local] xxxxxxxxxx => Local4 | {'cmd': 'dimmable', 'ltype': 'white', 'white': {'br': 100, 'ct': 255}} <= {'sequence': '1657098904000', 'encrypt': True, 'seq': 6, 'error': 400}
I think you can fix this by changing the conversion max values from 255 to 100. I tried making changes on my local file and it seems to work.
https://github.com/AlexxIT/SonoffLAN/blob/c317407a09e5c5e9aaf2a95e044e5afb5a367dec/custom_components/sonoff/light.py#L324 https://github.com/AlexxIT/SonoffLAN/blob/c317407a09e5c5e9aaf2a95e044e5afb5a367dec/custom_components/sonoff/light.py#L335 https://github.com/AlexxIT/SonoffLAN/blob/c317407a09e5c5e9aaf2a95e044e5afb5a367dec/custom_components/sonoff/light.py#L385 https://github.com/AlexxIT/SonoffLAN/blob/c317407a09e5c5e9aaf2a95e044e5afb5a367dec/custom_components/sonoff/light.py#L400
I never did a pull request, I try to learn how to do it and attach here if I succeed 😃
Regards. Maurizio
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 22 (5 by maintainers)
Commits related to this issue
- Fix support color_temp for B05-BL #890 — committed to AlexxIT/SonoffLAN by AlexxIT a year ago
Sorry for very-very long delay. Should be fixed in latest master version. Will be in the next release
No problem man, I was modifying the code on my installation by myself every new release, it was not so hard and long. Thanks for your work !