From f772e8cbc3c7674c2ca9a72d281abbe009aa40c2 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 10 Nov 2026 13:55:59 +0100 Subject: [PATCH] Add action enums to overkiz (#191860) --- homeassistant/components/overkiz/const.py | 14 ++++++++++++++ homeassistant/components/overkiz/cover.py | 6 +++--- homeassistant/components/overkiz/services.py | 17 +++++------------ 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/homeassistant/components/overkiz/const.py b/homeassistant/components/overkiz/const.py index 3a5008bb2f05..dc4d0473482f 100644 --- a/homeassistant/components/overkiz/const.py +++ b/homeassistant/components/overkiz/const.py @@ -1,6 +1,7 @@ """Constants for the Overkiz (by Somfy) integration.""" from datetime import timedelta +from enum import StrEnum import logging from typing import Final @@ -193,3 +194,16 @@ OVERKIZ_UNIT_TO_HA: dict[str, str] = { MeasuredValueType.VOLUME_IN_GALLON: UnitOfVolume.GALLONS, MeasuredValueType.VOLUME_IN_LITER: UnitOfVolume.LITERS, } + + +class OverkizService(StrEnum): + """Store keys for Overkiz services.""" + + SET_COVER_POSITION_AND_TILT = "set_cover_position_and_tilt" + + +class OverkizServiceArgument(StrEnum): + """Store keys for Overkiz service arguments.""" + + POSITION = "position" + TILT_POSITION = "tilt_position" diff --git a/homeassistant/components/overkiz/cover.py b/homeassistant/components/overkiz/cover.py index 7119beca958b..81291f0865c4 100644 --- a/homeassistant/components/overkiz/cover.py +++ b/homeassistant/components/overkiz/cover.py @@ -37,7 +37,7 @@ from homeassistant.helpers.issue_registry import ( from homeassistant.helpers.start import async_at_started from . import OverkizDataConfigEntry -from .const import DOMAIN, LOGGER +from .const import DOMAIN, LOGGER, OverkizServiceArgument from .coordinator import OverkizDataUpdateCoordinator, OverkizDeviceCommand from .entity import OverkizDescriptiveEntity @@ -939,8 +939,8 @@ class OverkizCover(OverkizDescriptiveEntity, CoverEntity): translation_key="unsupported_set_position_and_tilt", ) - position = kwargs[ATTR_POSITION] - tilt_position = kwargs[ATTR_TILT_POSITION] + position = kwargs[OverkizServiceArgument.POSITION] + tilt_position = kwargs[OverkizServiceArgument.TILT_POSITION] if self.entity_description.invert_position: position = 100 - position diff --git a/homeassistant/components/overkiz/services.py b/homeassistant/components/overkiz/services.py index de8ac405f26d..e7ded92946e6 100644 --- a/homeassistant/components/overkiz/services.py +++ b/homeassistant/components/overkiz/services.py @@ -2,18 +2,11 @@ import probatio -from homeassistant.components.cover import ( - ATTR_POSITION, - ATTR_TILT_POSITION, - DOMAIN as COVER_DOMAIN, - CoverEntityFeature, -) +from homeassistant.components.cover import DOMAIN as COVER_DOMAIN, CoverEntityFeature from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import service -from .const import DOMAIN - -SERVICE_SET_COVER_POSITION_AND_TILT = "set_cover_position_and_tilt" +from .const import DOMAIN, OverkizService, OverkizServiceArgument POSITION_MIN = 0 POSITION_MAX = 100 @@ -25,13 +18,13 @@ def async_setup_services(hass: HomeAssistant) -> None: service.async_register_platform_entity_service( hass, DOMAIN, - SERVICE_SET_COVER_POSITION_AND_TILT, + OverkizService.SET_COVER_POSITION_AND_TILT, entity_domain=COVER_DOMAIN, schema={ - probatio.Required(ATTR_POSITION): probatio.All( + probatio.Required(OverkizServiceArgument.POSITION): probatio.All( probatio.Coerce(int), probatio.Range(min=POSITION_MIN, max=POSITION_MAX) ), - probatio.Required(ATTR_TILT_POSITION): probatio.All( + probatio.Required(OverkizServiceArgument.TILT_POSITION): probatio.All( probatio.Coerce(int), probatio.Range(min=POSITION_MIN, max=POSITION_MAX) ), },