diff --git a/homeassistant/components/nina/const.py b/homeassistant/components/nina/const.py index fc433c8274ea..6303e8cc1a96 100644 --- a/homeassistant/components/nina/const.py +++ b/homeassistant/components/nina/const.py @@ -15,8 +15,6 @@ ALL_MATCH_REGEX: str = ".*" SEVERITY_VALUES: list[str] = ["extreme", "severe", "moderate", "minor", "unknown"] -SERVICE_GET_DETAILS: str = "get_details" - SERVICE_DATA_HEADLINE: str = "headline" SERVICE_DATA_DESCRIPTION: str = "description" SERVICE_DATA_SENDER: str = "sender" diff --git a/homeassistant/components/nina/services.py b/homeassistant/components/nina/services.py index b26e9394de25..7567910b8126 100644 --- a/homeassistant/components/nina/services.py +++ b/homeassistant/components/nina/services.py @@ -1,10 +1,18 @@ """Services for NINA.""" +from enum import StrEnum + from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN from homeassistant.core import HomeAssistant, SupportsResponse, callback from homeassistant.helpers import service -from .const import DOMAIN, SERVICE_GET_DETAILS +from .const import DOMAIN + + +class NinaService(StrEnum): + """Store keys for NINA services.""" + + GET_DETAILS = "get_details" @callback @@ -13,7 +21,7 @@ def async_setup_services(hass: HomeAssistant) -> None: service.async_register_platform_entity_service( hass, DOMAIN, - SERVICE_GET_DETAILS, + NinaService.GET_DETAILS, entity_domain=BINARY_SENSOR_DOMAIN, schema=None, func="get_details", diff --git a/tests/components/nina/test_service.py b/tests/components/nina/test_service.py index 0b4af66a4b1a..135e2058c93d 100644 --- a/tests/components/nina/test_service.py +++ b/tests/components/nina/test_service.py @@ -6,7 +6,8 @@ from pynina import Warning from pytest_homeassistant.common import MockConfigEntry from syrupy.assertion import SnapshotAssertion -from homeassistant.components.nina.const import DOMAIN, SERVICE_GET_DETAILS +from homeassistant.components.nina.const import DOMAIN +from homeassistant.components.nina.services import NinaService from homeassistant.const import ATTR_ENTITY_ID from homeassistant.core import HomeAssistant @@ -22,7 +23,7 @@ async def test_service_registration( services = hass.services.async_services_for_domain(DOMAIN) assert len(services) == 1 - assert SERVICE_GET_DETAILS in services + assert NinaService.GET_DETAILS in services async def test_service_get_details( @@ -39,7 +40,7 @@ async def test_service_get_details( result = await hass.services.async_call( DOMAIN, - SERVICE_GET_DETAILS, + NinaService.GET_DETAILS, {ATTR_ENTITY_ID: target_entity_id}, blocking=True, return_response=True, @@ -57,7 +58,7 @@ async def test_service_get_details_no_warning( result = await hass.services.async_call( DOMAIN, - SERVICE_GET_DETAILS, + NinaService.GET_DETAILS, {ATTR_ENTITY_ID: target_entity_id}, blocking=True, return_response=True,