mirror of
https://github.com/home-assistant/core.git
synced 2026-05-08 09:38:58 +01:00
max_temp / min_temp in modbus light could only be int, otherwise an assert was provoked. (#151833)
This commit is contained in:
@@ -267,8 +267,8 @@ CLIMATE_SCHEMA = vol.All(
|
||||
{
|
||||
vol.Required(CONF_TARGET_TEMP): hvac_fixedsize_reglist_validator,
|
||||
vol.Optional(CONF_TARGET_TEMP_WRITE_REGISTERS, default=False): cv.boolean,
|
||||
vol.Optional(CONF_MAX_TEMP, default=35): vol.Coerce(float),
|
||||
vol.Optional(CONF_MIN_TEMP, default=5): vol.Coerce(float),
|
||||
vol.Optional(CONF_MAX_TEMP, default=35): vol.Coerce(int),
|
||||
vol.Optional(CONF_MIN_TEMP, default=5): vol.Coerce(int),
|
||||
vol.Optional(CONF_STEP, default=0.5): vol.Coerce(float),
|
||||
vol.Optional(CONF_TEMPERATURE_UNIT, default=DEFAULT_TEMP_UNIT): cv.string,
|
||||
vol.Exclusive(CONF_HVAC_ONOFF_COIL, "hvac_onoff_type"): cv.positive_int,
|
||||
|
||||
@@ -64,7 +64,8 @@ class ModbusLight(BaseSwitch, LightEntity):
|
||||
self._attr_color_mode = self._detect_color_mode(config)
|
||||
self._attr_supported_color_modes = {self._attr_color_mode}
|
||||
|
||||
# Set min/max kelvin values if the mode is COLOR_TEMP
|
||||
self._attr_min_color_temp_kelvin: int = LIGHT_DEFAULT_MIN_KELVIN
|
||||
self._attr_max_color_temp_kelvin: int = LIGHT_DEFAULT_MAX_KELVIN
|
||||
if self._attr_color_mode == ColorMode.COLOR_TEMP:
|
||||
self._attr_min_color_temp_kelvin = config.get(
|
||||
CONF_MIN_TEMP, LIGHT_DEFAULT_MIN_KELVIN
|
||||
@@ -193,9 +194,6 @@ class ModbusLight(BaseSwitch, LightEntity):
|
||||
|
||||
def _convert_modbus_percent_to_temperature(self, percent: int) -> int:
|
||||
"""Convert Modbus scale (0-100) to the color temperature in Kelvin (2000-7000 К)."""
|
||||
assert isinstance(self._attr_min_color_temp_kelvin, int) and isinstance(
|
||||
self._attr_max_color_temp_kelvin, int
|
||||
)
|
||||
return round(
|
||||
self._attr_min_color_temp_kelvin
|
||||
+ (
|
||||
@@ -216,9 +214,6 @@ class ModbusLight(BaseSwitch, LightEntity):
|
||||
|
||||
def _convert_color_temp_to_modbus(self, kelvin: int) -> int:
|
||||
"""Convert color temperature from Kelvin to the Modbus scale (0-100)."""
|
||||
assert isinstance(self._attr_min_color_temp_kelvin, int) and isinstance(
|
||||
self._attr_max_color_temp_kelvin, int
|
||||
)
|
||||
return round(
|
||||
LIGHT_MODBUS_SCALE_MIN
|
||||
+ (kelvin - self._attr_min_color_temp_kelvin)
|
||||
|
||||
Reference in New Issue
Block a user