mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Update zwave_js supported features list to be static (#47623)
This commit is contained in:
parent
d9ffb65898
commit
797ee81fc9
@ -162,6 +162,15 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
|
||||
add_to_watched_value_ids=True,
|
||||
)
|
||||
self._set_modes_and_presets()
|
||||
self._supported_features = SUPPORT_PRESET_MODE
|
||||
# If any setpoint value exists, we can assume temperature
|
||||
# can be set
|
||||
if any(self._setpoint_values.values()):
|
||||
self._supported_features |= SUPPORT_TARGET_TEMPERATURE
|
||||
if HVAC_MODE_HEAT_COOL in self.hvac_modes:
|
||||
self._supported_features |= SUPPORT_TARGET_TEMPERATURE_RANGE
|
||||
if self._fan_mode:
|
||||
self._supported_features |= SUPPORT_FAN_MODE
|
||||
|
||||
def _setpoint_value(self, setpoint_type: ThermostatSetpointType) -> ZwaveValue:
|
||||
"""Optionally return a ZwaveValue for a setpoint."""
|
||||
@ -259,7 +268,7 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
|
||||
return None
|
||||
try:
|
||||
temp = self._setpoint_value(self._current_mode_setpoint_enums[0])
|
||||
except ValueError:
|
||||
except (IndexError, ValueError):
|
||||
return None
|
||||
return temp.value if temp else None
|
||||
|
||||
@ -271,7 +280,7 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
|
||||
return None
|
||||
try:
|
||||
temp = self._setpoint_value(self._current_mode_setpoint_enums[1])
|
||||
except ValueError:
|
||||
except (IndexError, ValueError):
|
||||
return None
|
||||
return temp.value if temp else None
|
||||
|
||||
@ -335,14 +344,7 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
|
||||
@property
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
support = SUPPORT_PRESET_MODE
|
||||
if len(self._current_mode_setpoint_enums) == 1:
|
||||
support |= SUPPORT_TARGET_TEMPERATURE
|
||||
if len(self._current_mode_setpoint_enums) > 1:
|
||||
support |= SUPPORT_TARGET_TEMPERATURE_RANGE
|
||||
if self._fan_mode:
|
||||
support |= SUPPORT_FAN_MODE
|
||||
return support
|
||||
return self._supported_features
|
||||
|
||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||
"""Set new target fan mode."""
|
||||
|
@ -24,9 +24,17 @@ from homeassistant.components.climate.const import (
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||
)
|
||||
from homeassistant.components.zwave_js.climate import ATTR_FAN_STATE
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_SUPPORTED_FEATURES,
|
||||
ATTR_TEMPERATURE,
|
||||
)
|
||||
|
||||
from .common import (
|
||||
CLIMATE_DANFOSS_LC13_ENTITY,
|
||||
@ -58,6 +66,13 @@ async def test_thermostat_v2(
|
||||
assert state.attributes[ATTR_PRESET_MODE] == PRESET_NONE
|
||||
assert state.attributes[ATTR_FAN_MODE] == "Auto low"
|
||||
assert state.attributes[ATTR_FAN_STATE] == "Idle / off"
|
||||
assert (
|
||||
state.attributes[ATTR_SUPPORTED_FEATURES]
|
||||
== SUPPORT_PRESET_MODE
|
||||
| SUPPORT_TARGET_TEMPERATURE
|
||||
| SUPPORT_TARGET_TEMPERATURE_RANGE
|
||||
| SUPPORT_FAN_MODE
|
||||
)
|
||||
|
||||
# Test setting preset mode
|
||||
await hass.services.async_call(
|
||||
@ -408,6 +423,10 @@ async def test_setpoint_thermostat(hass, client, climate_danfoss_lc_13, integrat
|
||||
assert state.attributes[ATTR_TEMPERATURE] == 14
|
||||
assert state.attributes[ATTR_HVAC_MODES] == [HVAC_MODE_HEAT]
|
||||
assert state.attributes[ATTR_PRESET_MODE] == PRESET_NONE
|
||||
assert (
|
||||
state.attributes[ATTR_SUPPORTED_FEATURES]
|
||||
== SUPPORT_PRESET_MODE | SUPPORT_TARGET_TEMPERATURE
|
||||
)
|
||||
|
||||
client.async_send_command_no_wait.reset_mock()
|
||||
|
||||
@ -491,6 +510,10 @@ async def test_thermostat_heatit(hass, client, climate_heatit_z_trm3, integratio
|
||||
assert state.attributes[ATTR_TEMPERATURE] == 22.5
|
||||
assert state.attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
|
||||
assert state.attributes[ATTR_PRESET_MODE] == PRESET_NONE
|
||||
assert (
|
||||
state.attributes[ATTR_SUPPORTED_FEATURES]
|
||||
== SUPPORT_PRESET_MODE | SUPPORT_TARGET_TEMPERATURE
|
||||
)
|
||||
|
||||
|
||||
async def test_thermostat_srt321_hrt4_zw(hass, client, srt321_hrt4_zw, integration):
|
||||
@ -507,3 +530,4 @@ async def test_thermostat_srt321_hrt4_zw(hass, client, srt321_hrt4_zw, integrati
|
||||
HVAC_MODE_HEAT,
|
||||
]
|
||||
assert state.attributes[ATTR_CURRENT_TEMPERATURE] is None
|
||||
assert state.attributes[ATTR_SUPPORTED_FEATURES] == SUPPORT_PRESET_MODE
|
||||
|
Loading…
x
Reference in New Issue
Block a user