Hi there, I am having some challenges with the code below - I have battled with this for hours (days if I’m to be honest ) and just can’t see what the issue is.
My goal is to use a timestamp as part of the name of the camera snapshot image and then add that to the android notification image address string.
I am using an input_text to create the timestamp (to ensure consistency between timestamp creation and its use in the camera.snapshot and notify.android_devices service calls.
I have a DDNS setup and can access from external as required - I’ve tested accessing the image directly (works) and I’ve tested the code below with the hardcode filename into the image address string (as per the comments rows -works).
BUT if I try to set the image string dynamically using “states(‘input_test.garage_photo’)”, the image isn’t loaded in the android notification.
I’m sure its a simple solution but it is just escaping me - I would really appreciate some help…
#Configuration for Garage Notifications
- alias: Notify mobiles when the garage is open
trigger:
- platform: time_pattern
minutes: '/10'
condition:
- condition: state
entity_id: binary_sensor.garage
state: 'on'
- condition: template
value_template: '{{ ((as_timestamp(now()) - as_timestamp(states.binary_sensor.garage.last_changed) | default(0)) | int) > 600 }}'
action:
- service: input_text.set_value
entity_id: input_text.garage_photo
data_template:
value: "camera_images/garage_{{ as_timestamp(now()) | timestamp_custom('%Y%m%d_%H%M_%S') }}.jpg"
- service: camera.snapshot
data:
entity_id: camera.rear_driveway_camera
filename: "/config/www/{{ states('input_text.garage_photo') }}"
# filename: "/config/www/camera_images/garage_20200824_1035_30.jpg"
- service: notify.android_devices
data:
message: "Garage door has been open for {{ relative_time(states.binary_sensor.garage.last_changed) }}"
data:
tag: garage_msg
image: "https://<external_domain_ip>/local/{{ states('input_text.garage_photo') }}"
# image: "https://<external_domain_ip>/local/camera_images/garage_20200824_1035_30.jpg"
ttl: 0
priority: high
clickAction: '/lovelace/cameras'
sticky: 'true'
actions:
- action: "close_garage"