diff --git a/morse-code-blinker/custom_components/morse_code_blinker/__init__.py b/morse-code-blinker/custom_components/morse_code_blinker/__init__.py index f7885a9..c94bae6 100644 --- a/morse-code-blinker/custom_components/morse_code_blinker/__init__.py +++ b/morse-code-blinker/custom_components/morse_code_blinker/__init__.py @@ -35,24 +35,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: _LOGGER.debug("Service call received: %s", call.data) from .service import async_blink_morse_code - # Combine target entity_ids with data + # Get data from service call + # The target selector in services.yaml automatically adds entity_id to call.data data = dict(call.data) - _LOGGER.debug("Service call target: %s", call.target) - - # Handle target selector (from services.yaml) - if call.target: - target_entity_id = None - if hasattr(call.target, "entity_id"): - target_entity_id = call.target.entity_id - elif isinstance(call.target, dict): - target_entity_id = call.target.get("entity_id") - - if target_entity_id: - if "entity_id" not in data: - data["entity_id"] = target_entity_id - elif isinstance(data["entity_id"], str) and data["entity_id"] != target_entity_id: - # If both are provided and different, prefer the explicit one in data - _LOGGER.warning("Both target and data have entity_id, using data value") # Normalize entity_id to list if it's a string if "entity_id" in data and isinstance(data["entity_id"], str):