Skip to content

Commit b8d9883

Browse files
janiversenfrenck
authored andcommitted
max_temp / min_temp in modbus light could only be int, otherwise an assert was provoked. (home-assistant#151833)
1 parent c3c65af commit b8d9883

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

homeassistant/components/modbus/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@
267267
{
268268
vol.Required(CONF_TARGET_TEMP): hvac_fixedsize_reglist_validator,
269269
vol.Optional(CONF_TARGET_TEMP_WRITE_REGISTERS, default=False): cv.boolean,
270-
vol.Optional(CONF_MAX_TEMP, default=35): vol.Coerce(float),
271-
vol.Optional(CONF_MIN_TEMP, default=5): vol.Coerce(float),
270+
vol.Optional(CONF_MAX_TEMP, default=35): vol.Coerce(int),
271+
vol.Optional(CONF_MIN_TEMP, default=5): vol.Coerce(int),
272272
vol.Optional(CONF_STEP, default=0.5): vol.Coerce(float),
273273
vol.Optional(CONF_TEMPERATURE_UNIT, default=DEFAULT_TEMP_UNIT): cv.string,
274274
vol.Exclusive(CONF_HVAC_ONOFF_COIL, "hvac_onoff_type"): cv.positive_int,

homeassistant/components/modbus/light.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def __init__(
6464
self._attr_color_mode = self._detect_color_mode(config)
6565
self._attr_supported_color_modes = {self._attr_color_mode}
6666

67-
# Set min/max kelvin values if the mode is COLOR_TEMP
67+
self._attr_min_color_temp_kelvin: int = LIGHT_DEFAULT_MIN_KELVIN
68+
self._attr_max_color_temp_kelvin: int = LIGHT_DEFAULT_MAX_KELVIN
6869
if self._attr_color_mode == ColorMode.COLOR_TEMP:
6970
self._attr_min_color_temp_kelvin = config.get(
7071
CONF_MIN_TEMP, LIGHT_DEFAULT_MIN_KELVIN
@@ -193,9 +194,6 @@ def _convert_modbus_percent_to_brightness(percent: int) -> int:
193194

194195
def _convert_modbus_percent_to_temperature(self, percent: int) -> int:
195196
"""Convert Modbus scale (0-100) to the color temperature in Kelvin (2000-7000 К)."""
196-
assert isinstance(self._attr_min_color_temp_kelvin, int) and isinstance(
197-
self._attr_max_color_temp_kelvin, int
198-
)
199197
return round(
200198
self._attr_min_color_temp_kelvin
201199
+ (
@@ -216,9 +214,6 @@ def _convert_brightness_to_modbus(brightness: int) -> int:
216214

217215
def _convert_color_temp_to_modbus(self, kelvin: int) -> int:
218216
"""Convert color temperature from Kelvin to the Modbus scale (0-100)."""
219-
assert isinstance(self._attr_min_color_temp_kelvin, int) and isinstance(
220-
self._attr_max_color_temp_kelvin, int
221-
)
222217
return round(
223218
LIGHT_MODBUS_SCALE_MIN
224219
+ (kelvin - self._attr_min_color_temp_kelvin)

0 commit comments

Comments
 (0)