Skip to content

Light: Problems setting color temperature #125

@forderud

Description

@forderud

I'm experiencing the following problem when attempting to set the color temperature on my KAJPLATS light bulb:

Traceback (most recent call last):
  File "C:\Dev\DirigeraMatter\DirigeraMotionDetect.py", line 88, in <module>
    light.set_color_temperature(448) # [153, 454]
  File "C:\Program Files\Python310\lib\site-packages\dirigera\devices\light.py", line 68, in set_color_temperature
    raise ValueError(
ValueError: color_temperature must be a value between 454 and 153

It seems like the problem is caused by the following color temperature range check in src/dirigera/devices/light.py:

if (
    color_temp < self.attributes.color_temperature_max
    or color_temp > self.attributes.color_temperature_min
):
    raise ValueError(
        "color_temperature must be a value between "
        f"{self.attributes.color_temperature_max} and {self.attributes.color_temperature_min}"
    )

The range check currently fails if the requested temperature is within the valid range. I think the logic should be inverted, so that it instead fails if the temperature is outside the valid range.

Light bulb metadata

id='92655f97-40bb-4474-a2a4-ae80d7deafe2_1' relation_id=None type='light' device_type='light' created_at=datetime.datetime(2026, 1, 14, 16, 0, 19, tzinfo=TzInfo(0)) is_reachable=True last_seen=datetime.datetime(2026, 1, 18, 14, 14, 35, tzinfo=TzInfo(0)) attributes=LightAttributes(custom_name='KAJPLATS E27 WS G60 clear', model='KAJPLATS E27 WS G60 clear 470lm', manufacturer='IKEA of Sweden', firmware_version='1.0.28', hardware_version='P2.0', serial_number='UNKNOWN_SERIAL_NUMBER', product_code='LED2411G3', ota_status='upToDate', ota_state='readyToCheck', ota_progress=0, ota_policy='autoUpdate', ota_schedule_start=datetime.time(0, 0), ota_schedule_end=datetime.time(0, 0), startup_on_off=<StartupEnum.START_ON: 'startOn'>, is_on=True, light_level=100, color_temperature=4484, color_temperature_min=153, color_temperature_max=454, color_hue=None, color_saturation=None) capabilities=Capabilities(can_send=[], can_receive=['isOn', 'lightLevel', 'colorTemperature', 'customName', 'windowOpen']) room=Room(id='5cfee7ef-933a-481a-8a50-c5ee17a1eda8', name='Soverom ', color='ikea_yellow_no_24', icon='rooms_bed') device_set=[] remote_links=['66573228-5f71-4763-9889-35bc52cb1b1d_3'] is_hidden=False dirigera_client=<dirigera.hub.hub.Hub object at 0x00000146835C3F70>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions