For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /developers/blog/2024-07-24-climate-min-max-temperature-check.md.

Climate entity 现在验证 action call 中提供的温度

从 Home Assistant Core 2024.8 起,我们为 ClimateEntity 提供的温度 action call 实现了验证。

集成不再需要在其自己的设置温度方法(async_set_temperature/set_temperature)中进行此检查。

然而,集成正确指定 min_tempmax_temp 属性非常重要,否则如果验证失败,用户可能无法设置正确的温度。 同样,处理同时可在 CelsiusFahrenheit 下运行的设备的集成需要相应地转换其 min_tempmax_temp 值。

示例

将设备的原生 min/max 值转换为集成指定的 temperature_unit。


class MyClimateEntity(ClimateEntity):
    """我的 climate entity 的实现。"""

    @property
    def min_temp(self) -> float:
        """返回最低温度。"""
        return TemperatureConverter.convert(
                self.device.min_temp, UnitOfTemperature.CELSIUS, self.temperature_unit
            )

    @property
    def max_temp(self) -> float:
        """返回最高温度。"""
        return TemperatureConverter.convert(
                self.device.max_temp, UnitOfTemperature.CELSIUS, self.temperature_unit
            )