mirror of
https://github.com/home-assistant/core.git
synced 2026-12-06 13:45:55 -04:00
Add action enums to nws (#191736)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
"""Services for the National Weather Service (NWS) integration."""
|
||||
|
||||
from enum import StrEnum
|
||||
|
||||
import probatio
|
||||
|
||||
from homeassistant.components.weather import DOMAIN as WEATHER_DOMAIN
|
||||
@@ -9,6 +11,18 @@ from homeassistant.helpers import service
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
class NWSService(StrEnum):
|
||||
"""Store keys for National Weather Service (NWS) services."""
|
||||
|
||||
GET_FORECASTS_EXTRA = "get_forecasts_extra"
|
||||
|
||||
|
||||
class NWSServiceArgument(StrEnum):
|
||||
"""Store keys for National Weather Service (NWS) service arguments."""
|
||||
|
||||
TYPE = "type"
|
||||
|
||||
|
||||
@callback
|
||||
def async_setup_services(hass: HomeAssistant) -> None:
|
||||
"""Set up the services for the National Weather Service (NWS) integration."""
|
||||
@@ -16,9 +30,13 @@ def async_setup_services(hass: HomeAssistant) -> None:
|
||||
service.async_register_platform_entity_service(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"get_forecasts_extra",
|
||||
NWSService.GET_FORECASTS_EXTRA,
|
||||
entity_domain=WEATHER_DOMAIN,
|
||||
schema={probatio.Required("type"): probatio.In(("hourly", "twice_daily"))},
|
||||
schema={
|
||||
probatio.Required(NWSServiceArgument.TYPE): probatio.In(
|
||||
("hourly", "twice_daily")
|
||||
)
|
||||
},
|
||||
func="async_get_forecasts_extra_service",
|
||||
supports_response=SupportsResponse.ONLY,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user