Add new climate feature flags to esphome (#109428)
This commit is contained in:
parent
baa511b808
commit
9831da34ce
3 changed files with 98 additions and 0 deletions
|
@ -14,6 +14,7 @@ from aioesphomeapi import (
|
|||
ClimateState,
|
||||
ClimateSwingMode,
|
||||
)
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
ATTR_CURRENT_HUMIDITY,
|
||||
|
@ -432,3 +433,59 @@ async def test_climate_entity_with_inf_value(
|
|||
assert attributes[ATTR_MIN_HUMIDITY] == 10
|
||||
assert ATTR_TEMPERATURE not in attributes
|
||||
assert attributes[ATTR_CURRENT_TEMPERATURE] is None
|
||||
|
||||
|
||||
async def test_climate_entity_attributes(
|
||||
hass: HomeAssistant,
|
||||
mock_client: APIClient,
|
||||
mock_generic_device_entry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test a climate entity sets correct attributes."""
|
||||
entity_info = [
|
||||
ClimateInfo(
|
||||
object_id="myclimate",
|
||||
key=1,
|
||||
name="my climate",
|
||||
unique_id="my_climate",
|
||||
supports_current_temperature=True,
|
||||
visual_target_temperature_step=2,
|
||||
visual_current_temperature_step=2,
|
||||
supports_action=True,
|
||||
visual_min_temperature=10.0,
|
||||
visual_max_temperature=30.0,
|
||||
supported_fan_modes=[ClimateFanMode.LOW, ClimateFanMode.HIGH],
|
||||
supported_modes=[
|
||||
ClimateMode.COOL,
|
||||
ClimateMode.HEAT,
|
||||
ClimateMode.AUTO,
|
||||
ClimateMode.OFF,
|
||||
],
|
||||
supported_presets=[ClimatePreset.AWAY, ClimatePreset.ACTIVITY],
|
||||
supported_custom_presets=["preset1", "preset2"],
|
||||
supported_custom_fan_modes=["fan1", "fan2"],
|
||||
supported_swing_modes=[ClimateSwingMode.BOTH, ClimateSwingMode.OFF],
|
||||
)
|
||||
]
|
||||
states = [
|
||||
ClimateState(
|
||||
key=1,
|
||||
mode=ClimateMode.COOL,
|
||||
action=ClimateAction.COOLING,
|
||||
current_temperature=30,
|
||||
target_temperature=20,
|
||||
fan_mode=ClimateFanMode.AUTO,
|
||||
swing_mode=ClimateSwingMode.BOTH,
|
||||
)
|
||||
]
|
||||
user_service = []
|
||||
await mock_generic_device_entry(
|
||||
mock_client=mock_client,
|
||||
entity_info=entity_info,
|
||||
user_service=user_service,
|
||||
states=states,
|
||||
)
|
||||
state = hass.states.get("climate.test_myclimate")
|
||||
assert state is not None
|
||||
assert state.state == HVACMode.COOL
|
||||
assert state.attributes == snapshot(name="climate-entity-attributes")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue