mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Add action enums to advantage_air (#189961)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
"""Constants used by Advantage Air integration."""
|
||||
|
||||
from enum import StrEnum
|
||||
|
||||
DOMAIN = "advantage_air"
|
||||
ADVANTAGE_AIR_RETRY = 10
|
||||
ADVANTAGE_AIR_STATE_OPEN = "open"
|
||||
@@ -8,3 +10,15 @@ ADVANTAGE_AIR_STATE_ON = "on"
|
||||
ADVANTAGE_AIR_STATE_OFF = "off"
|
||||
ADVANTAGE_AIR_AUTOFAN_ENABLED = "aaAutoFanModeEnabled"
|
||||
ADVANTAGE_AIR_NIGHT_MODE_ENABLED = "quietNightModeEnabled"
|
||||
|
||||
|
||||
class AdvantageAirService(StrEnum):
|
||||
"""Store keys for Advantage Air services."""
|
||||
|
||||
SET_TIME_TO = "set_time_to"
|
||||
|
||||
|
||||
class AdvantageAirServiceArgument(StrEnum):
|
||||
"""Store keys for Advantage Air service arguments."""
|
||||
|
||||
MINUTES = "minutes"
|
||||
|
||||
@@ -12,11 +12,10 @@ from homeassistant.const import PERCENTAGE, EntityCategory, UnitOfTemperature
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from .const import ADVANTAGE_AIR_STATE_OPEN
|
||||
from .const import ADVANTAGE_AIR_STATE_OPEN, AdvantageAirServiceArgument
|
||||
from .coordinator import AdvantageAirCoordinator, AdvantageAirDataConfigEntry
|
||||
from .entity import AdvantageAirAcEntity, AdvantageAirZoneEntity
|
||||
|
||||
ADVANTAGE_AIR_SET_COUNTDOWN_VALUE = "minutes"
|
||||
ADVANTAGE_AIR_SET_COUNTDOWN_UNIT = "min"
|
||||
|
||||
PARALLEL_UPDATES = 0
|
||||
@@ -81,7 +80,7 @@ class AdvantageAirTimeTo(AdvantageAirAcEntity, SensorEntity):
|
||||
|
||||
async def set_time_to(self, **kwargs: Any) -> None:
|
||||
"""Set the timer value."""
|
||||
value = min(720, max(0, int(kwargs[ADVANTAGE_AIR_SET_COUNTDOWN_VALUE])))
|
||||
value = min(720, max(0, int(kwargs[AdvantageAirServiceArgument.MINUTES])))
|
||||
await self.async_update_ac({self._time_key: value})
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import config_validation as cv, service
|
||||
|
||||
from .const import DOMAIN
|
||||
from .const import DOMAIN, AdvantageAirService, AdvantageAirServiceArgument
|
||||
|
||||
|
||||
@callback
|
||||
@@ -16,8 +16,10 @@ def async_setup_services(hass: HomeAssistant) -> None:
|
||||
service.async_register_platform_entity_service(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"set_time_to",
|
||||
AdvantageAirService.SET_TIME_TO,
|
||||
entity_domain=SENSOR_DOMAIN,
|
||||
schema={probatio.Required("minutes"): cv.positive_int},
|
||||
schema={
|
||||
probatio.Required(AdvantageAirServiceArgument.MINUTES): cv.positive_int
|
||||
},
|
||||
func="set_time_to",
|
||||
)
|
||||
|
||||
@@ -5,9 +5,10 @@ from unittest.mock import AsyncMock, patch
|
||||
|
||||
from pytest_homeassistant.common import async_fire_time_changed
|
||||
|
||||
from homeassistant.components.advantage_air.const import DOMAIN
|
||||
from homeassistant.components.advantage_air.sensor import (
|
||||
ADVANTAGE_AIR_SET_COUNTDOWN_VALUE,
|
||||
from homeassistant.components.advantage_air.const import (
|
||||
DOMAIN,
|
||||
AdvantageAirService,
|
||||
AdvantageAirServiceArgument,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -41,8 +42,8 @@ async def test_sensor_platform(
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
"set_time_to",
|
||||
{ATTR_ENTITY_ID: [entity_id], ADVANTAGE_AIR_SET_COUNTDOWN_VALUE: value},
|
||||
AdvantageAirService.SET_TIME_TO,
|
||||
{ATTR_ENTITY_ID: [entity_id], AdvantageAirServiceArgument.MINUTES: value},
|
||||
blocking=True,
|
||||
)
|
||||
mock_update.assert_called_once()
|
||||
@@ -61,8 +62,8 @@ async def test_sensor_platform(
|
||||
value = 0
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
"set_time_to",
|
||||
{ATTR_ENTITY_ID: [entity_id], ADVANTAGE_AIR_SET_COUNTDOWN_VALUE: value},
|
||||
AdvantageAirService.SET_TIME_TO,
|
||||
{ATTR_ENTITY_ID: [entity_id], AdvantageAirServiceArgument.MINUTES: value},
|
||||
blocking=True,
|
||||
)
|
||||
mock_update.assert_called_once()
|
||||
|
||||
Reference in New Issue
Block a user