diff --git a/src/common/services/IssueService/locale.json b/src/common/services/IssueService/locale.json index f7e81cb202..b613f8b92e 100644 --- a/src/common/services/IssueService/locale.json +++ b/src/common/services/IssueService/locale.json @@ -3,6 +3,7 @@ "service": { "issue": { "device_not_found": "Device __device_id__ not found", + "entity_id_target_data": "Entity ID '__entity_id__' should be in the data property, not the target property, for the selected action", "entity_not_found": "Entity __entity_id__ not found", "failed_to_hide": "Failed to hide issue __issue_id__", "invalid_action": "Action __action__ not found", diff --git a/src/nodes/action/issue-check.ts b/src/nodes/action/issue-check.ts index 96076fca76..8f8e2a399c 100644 --- a/src/nodes/action/issue-check.ts +++ b/src/nodes/action/issue-check.ts @@ -78,6 +78,30 @@ export default function issueCheck(config: ActionNodeProperties): Issue[] { message, identity: config.action, }); + } else { + // TODO: Remove in version 1.0 - Should no longer be needed + // check if target.entity_id should be in data.entity_id + if (services[domain]?.[service]?.fields?.entity_id !== undefined) { + let data: Record = {}; + try { + data = JSON.parse(config.data || '{}'); + } catch (e) { + // fail silently + } + if (config.entityId?.length && !data.entity_id) { + const ids = config.entityId.join(', '); + issues.push({ + type: IssueType.EntityId, + message: RED._( + 'home-assistant.service.issue.entity_id_target_data', + { + entity_id: ids, + }, + ), + identity: ids, + }); + } + } } } @@ -89,6 +113,8 @@ export default function issueCheck(config: ActionNodeProperties): Issue[] { config[target.idsProperty], ); for (const id of invalidIds) { + // Skip the 'all' entity id if the target is entityId + // https://www.home-assistant.io/docs/scripts/perform-actions/#the-basics if (id === 'all' && target.idsProperty === 'entityId') { continue; }