diff --git a/homeassistant/components/automation/blueprints/notify_leaving_zone.yaml b/homeassistant/components/automation/blueprints/notify_leaving_zone.yaml index 5b64a090a07..9b79396f066 100644 --- a/homeassistant/components/automation/blueprints/notify_leaving_zone.yaml +++ b/homeassistant/components/automation/blueprints/notify_leaving_zone.yaml @@ -27,6 +27,8 @@ trigger: variables: zone_entity: !input zone_entity zone_state: "{{ states[zone_entity].name }}" + person_entity: !input person_entity + person_name: "{{ states[person_entity].name }}" condition: condition: template @@ -36,4 +38,4 @@ action: domain: mobile_app type: notify device_id: !input notify_device - message: "{{ trigger.to_state.name }} has left {{ zone_state }}" + message: "{{ person_name }} has left {{ zone_state }}" diff --git a/tests/components/automation/test_blueprint.py b/tests/components/automation/test_blueprint.py index 568087840c4..56062af17b7 100644 --- a/tests/components/automation/test_blueprint.py +++ b/tests/components/automation/test_blueprint.py @@ -115,6 +115,15 @@ async def test_notify_leaving_zone(hass): assert len(mock_call_action.mock_calls) == 2 + # Verify trigger works + await hass.services.async_call( + "automation", + "trigger", + {"entity_id": "automation.automation_0"}, + blocking=True, + ) + assert len(mock_call_action.mock_calls) == 3 + async def test_motion_light(hass): """Test motion light blueprint.""" @@ -192,3 +201,13 @@ async def test_motion_light(hass): assert len(turn_on_calls) == 3 assert len(turn_off_calls) == 1 + + # Verify trigger works + await hass.services.async_call( + "automation", + "trigger", + {"entity_id": "automation.automation_0"}, + ) + for _ in range(25): + await asyncio.sleep(0) + assert len(turn_on_calls) == 4