diff --git a/homeassistant/components/simplisafe/services.py b/homeassistant/components/simplisafe/services.py index 7dc5f5425145..ef898794674a 100644 --- a/homeassistant/components/simplisafe/services.py +++ b/homeassistant/components/simplisafe/services.py @@ -18,12 +18,12 @@ from simplipy.system.v3 import ( ) import voluptuous as vol -from homeassistant.config_entries import ConfigEntryState from homeassistant.const import ATTR_DEVICE_ID from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.exceptions import HomeAssistantError, ServiceValidationError from homeassistant.helpers import config_validation as cv, device_registry as dr from homeassistant.helpers.service import ( + async_get_device_and_config_entry, async_register_admin_service, verify_domain_control, ) @@ -135,34 +135,18 @@ def _async_get_system_for_service_call(call: ServiceCall) -> SystemType: if TYPE_CHECKING: assert alarm_control_panel_device_entry.via_device_id - config_entry: SimpliSafeConfigEntry | None - base_station_device_entry, config_entry = ( - dr.async_get_device_and_config_entry_for_domain( - call.hass, alarm_control_panel_device_entry.via_device_id, domain=DOMAIN - ) + config_entry: SimpliSafeConfigEntry + base_station_device_entry, config_entry = async_get_device_and_config_entry( + call.hass, DOMAIN, alarm_control_panel_device_entry.via_device_id ) - if base_station_device_entry is None: - raise ServiceValidationError( - translation_domain=DOMAIN, - translation_key="no_base_station", - translation_placeholders={"device_id": device_id}, - ) [system_id_str] = [ identity[1] for identity in base_station_device_entry.identifiers if identity[0] == DOMAIN ] - system_id = int(system_id_str) - if config_entry is None or config_entry.state is not ConfigEntryState.LOADED: - raise ServiceValidationError( - translation_domain=DOMAIN, - translation_key="no_system_for_device", - translation_placeholders={"device_id": device_id}, - ) - - return config_entry.runtime_data.systems[system_id] + return config_entry.runtime_data.systems[int(system_id_str)] @callback diff --git a/homeassistant/components/simplisafe/strings.json b/homeassistant/components/simplisafe/strings.json index 2e858766e2e5..1f128522e0f4 100644 --- a/homeassistant/components/simplisafe/strings.json +++ b/homeassistant/components/simplisafe/strings.json @@ -34,12 +34,6 @@ "invalid_device_id": { "message": "No device could be found for ID: {device_id}" }, - "no_base_station": { - "message": "No base station could be found for device ID: {device_id}" - }, - "no_system_for_device": { - "message": "No SimpliSafe system could be found for device ID: {device_id}" - }, "set_system_properties_not_v3": { "message": "System properties can only be set on V3 systems." }