I’m trying to create an automation that sends me a notification when I’m not home and any of the doors are unlocked. In general it works great but I would also like to include a security camera photo in the notification and I can’t get that to work.
If I don’t use a template for image it works:
device_id: a02a1897d773538bb0b51499361a32ba
domain: mobile_app
type: notify
title: No one is home and at least one door is unlocked
message: >-
Open locks: {{ expand('lock.all_locks')|selectattr('state', '==',
'unlocked')|map(attribute='name')|join(', ') }}. If no one is home you should
lock the doors
data:
notification_icon: mdi:lock-open
image: /api/camera_proxy/camera.front
persistent: true
sticky: true
tag: unlocked_door
actions:
- action: unlocked_door_lock
title: Lock All Doors
- action: ignore
title: Ignore
But if I try:
image: "/api/camera_proxy/camera.{{ expand('lock.all_locks')|selectattr('state', '==', 'unlocked')|map(attribute='entity_id')|first|replace('lock.', '')|replace('_door', '') }}"
Even if I verified in the template debugger that it generate /api/camera_proxy/camera.front
I also tried:
{{ state_attr('camera.'+expand('lock.all_locks')|selectattr('state', '==', 'unlocked')|map(attribute='entity_id')|first|replace('lock.', '')|replace('_door', ''), 'entity_picture') }}
which generate according to the template debugger: /api/camera_proxy/camera.front?token=40faf9d...
I tried turning on debug logging for homeassistant.components.automation
to see what happen with the template if anything but I can’t see anything in the logs.
Is it even possible to use templates in the image
?