hass-circadian_lighting
hass-circadian_lighting copied to clipboard
Circadian Lighting not setting Color Temperature of Xiaomi Desk Lamp
I have a Xiaomi Desk Lamp setup in HomeAssistant, and it's working as expected:
Curiously, although I can configure the brightness and color temperature via Home Assistant, the circadian lighting component does not adjust colour temperature (but brightness works). In fact, it seems to generate the following error:
2019-10-07 21:11:46 ERROR (SyncWorker_12) [homeassistant.components.yeelight.light] Error when calling <function YeelightGenericLight.set_colortemp at 0x6ed219c0>: {'code': -5000, 'message': 'general error'}
2019-10-07 21:11:46 ERROR (SyncWorker_5) [homeassistant.components.yeelight.light] Error when calling <function YeelightGenericLight.set_colortemp at 0x6ed219c0>: {'code': -5000, 'message': 'general error'}
2019-10-07 21:15:15 ERROR (SyncWorker_6) [homeassistant.components.yeelight.light] Error when calling <function YeelightGenericLight.set_colortemp at 0x6ed219c0>: {'code': -5000, 'message': 'general error'}
2019-10-07 21:15:15 ERROR (SyncWorker_18) [homeassistant.components.yeelight.light] Error when calling <function YeelightGenericLight.set_colortemp at 0x6ed219c0>: {'code': -5000, 'message': 'general error'}
2019-10-07 21:15:17 ERROR (SyncWorker_16) [homeassistant.components.yeelight.light] Error when calling <function YeelightGenericLight.set_colortemp at 0x6ed219c0>: {'code': -5000, 'message': 'general error'}
2019-10-07 21:15:19 ERROR (SyncWorker_16) [homeassistant.components.yeelight.light] Error when calling <function YeelightGenericLight.set_colortemp at 0x6ed219c0>: {'code': -5000, 'message': 'general error'}
2019-10-07 21:15:48 ERROR (SyncWorker_8) [homeassistant.components.yeelight.light] Error when calling <function YeelightGenericLight.set_colortemp at 0x6ed219c0>: {'code': -5000, 'message': 'general error'}
I have a number of Yeelight bulbs and Milight bulbs (using Sidoh's Milight Hub) controlled using Circadian Lighting and working as expected. Only the Desk Lamp doesn't work.
Configuration.yaml
circadian_lighting:
min_colortemp: 1900
max_colortemp: 4000
interval: 30
transition: 10
yeelight:
devices:
192.168.1.188: # <----- Working bulb
name: Hallway
transition: 1000
192.168.1.182: # <----- Trouble Lamp
name: Desk Lamp
transition: 1000
switch:
- platform: circadian_lighting
name: Main
min_brightness: 20
max_brightness: 80
sleep_colortemp: 1000
sleep_brightness: 1
sleep_entity: input_boolean.sleepy_time
sleep_state: "on"
lights_ct:
- light.Desk_Lamp
- light.Hallway
Maybe also useful?
You have:
min_colortemp: 1900
max_colortemp: 4000
which is a range of ~250-526 mireds. The hallway light can handle that whole range, but mired values above 370 are outside of the range of the desk lamp.
Circadian Lighting should still work for that lamp when the color temperature is being set between 153-370 mireds (~2700-6500 k) - do you know if that is or is not the case?
I will check when I get home tonight. Though, without checking, I can confirm that Circadian does not adjust the lamp temperature to it's maximum if the Circadian temperature is too warm, which is the behavior I would have expected.
I will set the range to 3000-6000 and test tonight.
I can confirm that Circadian does not adjust the lamp temperature to it's maximum if the Circadian temperature is too warm, which is the behavior I would have expected.
This is the behavior I would expect as well - this is what happens with my Hue lights, but come to think of it, that's a result of the Hue API and not Home Assistant implementation.
So assuming this is the issue, the question is; should CL check the min/max mireds of every light every time an adjustment is sent to ensure it doesn't send a value outside that range, or should it be up to the user to configure the min_colortemp and max_colortemp appropriately so that CL doesn't need to query device attributes every adjustment.
or should it be up to the user to configure the min_colortemp and max_colortemp appropriately so that CL doesn't need to query device attributes every adjustment.
But then the user (me :P) would need to create different CL switches and settings for different groups of lights.
Actually, because color temperature is at the platform level not the switch level you're currently restricted to the lowest-common-denominator range for all lights. For that reason I'm leaning towards CL doing the attribute query...I just hate the idea of that extra overhead.
Not that this helps reduce the overhead but how about a simple “if temp to be set > lamp_max, set to lamp_max” and the same on the cool spectrum.
Hass (I feel) needs to expand to do things like automatically handling mix/max on all values, as well as custom curves and mappings (such as if a lamp has 3 brightnesses, specify the range that triggers each). That way addons can simplify.
Not that this helps reduce the overhead but how about a simple “if temp to be set > lamp_max, set to lamp_max” and the same on the cool spectrum.
That's basically what I was thinking, but finding lamp_max would require querying the max_mireds attribute.
should CL check the min/max mireds of every light every time an adjustment is sent to ensure it doesn't send a value outside that range
I would hella love this!
Okay, changing my config worked:
circadian_lighting:
# min_colortemp: 1900 # <--- Old Value
min_colortemp: 3000 # <--- New Value
max_colortemp: 4000
interval: 30
transition: 10
So you were right about the problem.
Not that this helps reduce the overhead but how about a simple “if temp to be set > lamp_max, set to lamp_max” and the same on the cool spectrum.
Is this something I should be putting in my config somewhere? or are you talking CL code here?
Is this something I should be putting in my config somewhere? or are you talking CL code here?
That would be in the CL code - until that's updated you have two options:
- Leave everything as it is, and lights that don't support the range won't be updated
- Configure
min_colortemp
andmax_colortemp
to be the lowest/highest that all lights can handle
Going with option 2 for now.
Thanks so much for your help :)
I'm getting the same error with default configuration.
Light is a Xiaomi Desk Lamp 1S.
2020-07-19 14:15:33 ERROR (SyncWorker_1) [homeassistant.components.yeelight.light] Error when calling <function YeelightGenericLight.set_colortemp at 0xa37758e8>: {'code': -5001, 'message': 'invalid params'}
2020-07-19 14:16:03 ERROR (SyncWorker_8) [homeassistant.components.yeelight.light] Error when calling <function YeelightGenericLight.set_colortemp at 0xa37758e8>: {'code': -5001, 'message': 'invalid params'}
switch:
- platform: circadian_lighting
lights_ct:
- light.desk_light
disable_brightness_adjust: true
yeelight:
devices:
10.0.0.50:
name: Desk Light
transition: 500
model: lamp4
![Screenshot 2020-07-19 14 32 45](https://user-images.githubusercontent.com/19761269/87871375-6e0c4d00-c9cd-11ea-9a7c-31130fe7e9c3.png)