Remove support for area, device, or entity targets for screenlogic actions (#123432)

* Remove non-configentry service target

* Remove unneeded tests

* Remove unneeded issue strings
This commit is contained in:
Kevin Worrel 2024-09-06 07:46:06 -07:00 committed by GitHub
parent c4cc158a77
commit f6c681eb5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 7 additions and 133 deletions

View file

@ -10,12 +10,7 @@ import voluptuous as vol
from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
from homeassistant.helpers import (
config_validation as cv,
issue_registry as ir,
selector,
)
from homeassistant.helpers.service import async_extract_config_entry_ids
from homeassistant.helpers import selector
from .const import (
ATTR_COLOR_MODE,
@ -44,19 +39,10 @@ BASE_SERVICE_SCHEMA = vol.Schema(
}
)
SET_COLOR_MODE_SCHEMA = vol.All(
vol.Schema(
{
vol.Optional(ATTR_CONFIG_ENTRY): selector.ConfigEntrySelector(
{
"integration": DOMAIN,
}
),
**cv.ENTITY_SERVICE_FIELDS,
vol.Required(ATTR_COLOR_MODE): vol.In(SUPPORTED_COLOR_MODES),
}
),
cv.has_at_least_one_key(ATTR_CONFIG_ENTRY, *cv.ENTITY_SERVICE_FIELDS),
SET_COLOR_MODE_SCHEMA = BASE_SERVICE_SCHEMA.extend(
{
vol.Required(ATTR_COLOR_MODE): vol.In(SUPPORTED_COLOR_MODES),
}
)
TURN_ON_SUPER_CHLOR_SCHEMA = BASE_SERVICE_SCHEMA.extend(
@ -72,37 +58,10 @@ TURN_ON_SUPER_CHLOR_SCHEMA = BASE_SERVICE_SCHEMA.extend(
def async_load_screenlogic_services(hass: HomeAssistant):
"""Set up services for the ScreenLogic integration."""
async def extract_screenlogic_config_entry_ids(service_call: ServiceCall):
if not (
screenlogic_entry_ids := await async_extract_config_entry_ids(
hass, service_call
)
):
raise ServiceValidationError(
f"Failed to call service '{service_call.service}'. Config entry for "
"target not found"
)
return screenlogic_entry_ids
async def get_coordinators(
service_call: ServiceCall,
) -> list[ScreenlogicDataUpdateCoordinator]:
entry_ids: set[str]
if entry_id := service_call.data.get(ATTR_CONFIG_ENTRY):
entry_ids = {entry_id}
else:
ir.async_create_issue(
hass,
DOMAIN,
"service_target_deprecation",
breaks_in_ha_version="2024.8.0",
is_fixable=True,
is_persistent=True,
severity=ir.IssueSeverity.WARNING,
translation_key="service_target_deprecation",
)
entry_ids = await extract_screenlogic_config_entry_ids(service_call)
entry_ids = {service_call.data[ATTR_CONFIG_ENTRY]}
coordinators: list[ScreenlogicDataUpdateCoordinator] = []
for entry_id in entry_ids:
config_entry = cast(