From 9189cc4c15671afab1fe7e7edc2a89d479a3104d Mon Sep 17 00:00:00 2001 From: Christopher Price <82070831+kitprice@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:01:22 -0600 Subject: [PATCH 1/2] Fix warning message for implicitly supporting turn_on/off methods in HVACModes Entity None () implements HVACMode(s): cool, heat, heat_cool, off and therefore implicitly supports the turn_on/turn_off methods without setting the proper ClimateEntityFeature. Please create a bug report at https://github.com/natekspencer/hacs-vivint/issues --- custom_components/vivint/climate.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/custom_components/vivint/climate.py b/custom_components/vivint/climate.py index ce74a19..0e07e5c 100644 --- a/custom_components/vivint/climate.py +++ b/custom_components/vivint/climate.py @@ -122,7 +122,10 @@ class VivintClimate(VivintEntity, ClimateEntity): ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.TARGET_TEMPERATURE_RANGE | ClimateEntityFeature.FAN_MODE + | ClimateEntityFeature.TURN_ON + | ClimateEntityFeature.TURN_OFF ) + _enable_turn_on_off_backwards_compatibility = False _attr_temperature_unit = UnitOfTemperature.CELSIUS def __init__(self, device: Thermostat, hub: VivintHub) -> None: @@ -209,12 +212,21 @@ async def async_set_fan_mode(self, fan_mode: str) -> None: } ) + async def async_set_hvac_mode(self, hvac_mode: str) -> None: """Set new target hvac mode.""" await self.device.set_state( **{ThermostatAttribute.OPERATING_MODE: VIVINT_HVAC_INV_MODE_MAP[hvac_mode]} ) + async def async_turn_on(self) -> None: + """Turn the entity on.""" + await self.async_set_hvac_mode(HVACMode.HEAT_COOL) + + async def async_turn_off(self) -> None: + """Turn the entity off.""" + await self.async_set_hvac_mode(HVACMode.OFF) + async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" temp = kwargs.get(ATTR_TEMPERATURE) From 18302d5c82927a0e28f898dfb51c5125b0cde299 Mon Sep 17 00:00:00 2001 From: Christopher Price <82070831+kitprice@users.noreply.github.com> Date: Wed, 18 Dec 2024 19:02:05 -0600 Subject: [PATCH 2/2] Cosmetic changes Move _enable_turn_on_off_backwards_compatibility after all _attr_* settings. Remove extra link break. --- custom_components/vivint/climate.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/custom_components/vivint/climate.py b/custom_components/vivint/climate.py index 0e07e5c..1cbe3bc 100644 --- a/custom_components/vivint/climate.py +++ b/custom_components/vivint/climate.py @@ -125,8 +125,8 @@ class VivintClimate(VivintEntity, ClimateEntity): | ClimateEntityFeature.TURN_ON | ClimateEntityFeature.TURN_OFF ) - _enable_turn_on_off_backwards_compatibility = False _attr_temperature_unit = UnitOfTemperature.CELSIUS + _enable_turn_on_off_backwards_compatibility = False def __init__(self, device: Thermostat, hub: VivintHub) -> None: """Pass coordinator to CoordinatorEntity.""" @@ -212,7 +212,6 @@ async def async_set_fan_mode(self, fan_mode: str) -> None: } ) - async def async_set_hvac_mode(self, hvac_mode: str) -> None: """Set new target hvac mode.""" await self.device.set_state(