Add action enums to nws (#191736)

This commit is contained in:
epenet
2026-11-10 08:04:27 +01:00
committed by GitHub
parent aa5c391cb8
commit 86c9d15967
+20 -2
View File
@@ -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,
)