diff --git a/homeassistant/components/knx/const.py b/homeassistant/components/knx/const.py index bacd678bb99..1ec89b47409 100644 --- a/homeassistant/components/knx/const.py +++ b/homeassistant/components/knx/const.py @@ -118,6 +118,7 @@ class ColorTempModes(Enum): """Color temperature modes for config validation.""" ABSOLUTE = "DPT-7.600" + ABSOLUTE_FLOAT = "DPT-9" RELATIVE = "DPT-5.001" diff --git a/homeassistant/components/knx/light.py b/homeassistant/components/knx/light.py index f5ef8f61b84..07747f094c3 100644 --- a/homeassistant/components/knx/light.py +++ b/homeassistant/components/knx/light.py @@ -4,7 +4,11 @@ from __future__ import annotations from typing import Any, cast from xknx import XKNX -from xknx.devices.light import Light as XknxLight, XYYColor +from xknx.devices.light import ( + ColorTemperatureType, + Light as XknxLight, + XYYColor, +) from homeassistant import config_entries from homeassistant.components.light import ( @@ -56,16 +60,20 @@ def _create_light(xknx: XKNX, config: ConfigType) -> XknxLight: group_address_tunable_white_state = None group_address_color_temp = None group_address_color_temp_state = None - if config[LightSchema.CONF_COLOR_TEMP_MODE] == ColorTempModes.ABSOLUTE: - group_address_color_temp = config.get(LightSchema.CONF_COLOR_TEMP_ADDRESS) - group_address_color_temp_state = config.get( - LightSchema.CONF_COLOR_TEMP_STATE_ADDRESS - ) - elif config[LightSchema.CONF_COLOR_TEMP_MODE] == ColorTempModes.RELATIVE: + color_temperature_type = ColorTemperatureType.UINT_2_BYTE + if config[LightSchema.CONF_COLOR_TEMP_MODE] == ColorTempModes.RELATIVE: group_address_tunable_white = config.get(LightSchema.CONF_COLOR_TEMP_ADDRESS) group_address_tunable_white_state = config.get( LightSchema.CONF_COLOR_TEMP_STATE_ADDRESS ) + else: + # absolute uint or float + group_address_color_temp = config.get(LightSchema.CONF_COLOR_TEMP_ADDRESS) + group_address_color_temp_state = config.get( + LightSchema.CONF_COLOR_TEMP_STATE_ADDRESS + ) + if config[LightSchema.CONF_COLOR_TEMP_MODE] == ColorTempModes.ABSOLUTE_FLOAT: + color_temperature_type = ColorTemperatureType.FLOAT_2_BYTE return XknxLight( xknx, @@ -140,6 +148,7 @@ def _create_light(xknx: XKNX, config: ConfigType) -> XknxLight: group_address_brightness_white_state=individual_color_addresses( LightSchema.CONF_WHITE, LightSchema.CONF_BRIGHTNESS_STATE_ADDRESS ), + color_temperature_type=color_temperature_type, min_kelvin=config[LightSchema.CONF_MIN_KELVIN], max_kelvin=config[LightSchema.CONF_MAX_KELVIN], ) @@ -239,7 +248,7 @@ class KNXLight(KnxEntity, LightEntity): """Return the color temperature in Kelvin.""" if self._device.supports_color_temperature: if kelvin := self._device.current_color_temperature: - return kelvin + return int(kelvin) if self._device.supports_tunable_white: relative_ct = self._device.current_tunable_white if relative_ct is not None: diff --git a/homeassistant/components/knx/manifest.json b/homeassistant/components/knx/manifest.json index 6cb6a4ffcf7..79b729017b2 100644 --- a/homeassistant/components/knx/manifest.json +++ b/homeassistant/components/knx/manifest.json @@ -11,7 +11,7 @@ "loggers": ["xknx", "xknxproject"], "quality_scale": "platinum", "requirements": [ - "xknx==2.10.0", + "xknx==2.11.0", "xknxproject==3.2.0", "knx-frontend==2023.6.23.191712" ] diff --git a/requirements_all.txt b/requirements_all.txt index 2546116f246..b6058900420 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2688,7 +2688,7 @@ xbox-webapi==2.0.11 xiaomi-ble==0.17.2 # homeassistant.components.knx -xknx==2.10.0 +xknx==2.11.0 # homeassistant.components.knx xknxproject==3.2.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index d323757226c..d91b73fb075 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1967,7 +1967,7 @@ xbox-webapi==2.0.11 xiaomi-ble==0.17.2 # homeassistant.components.knx -xknx==2.10.0 +xknx==2.11.0 # homeassistant.components.knx xknxproject==3.2.0