#Persistent Notification With Image

1 messages · Page 1 of 1 (latest)

craggy mica
#

I am taking and sending a camera snapshot in an automation with notify.persistent_notification and notify.mobile_device. The mobile shows the correct picture but the Persistent Notification in the App/Web GUI always shows the same picture unless I clear cache. What's the best solution? I tried using a variable for the snapshot to make the name unique like this but the snapshot fails:
variables: snapshot_filename: /config/www/tmp/snapshot_uvc_front_door_{{now().strftime('%Y%m%d_%H%M%S')}}.jpg snapshot_url: /local/tmp/snapshot_uvc_front_door_{{now().strftime('%Y%m%d_%H%M%S')}}.jpg

craggy mica
#

It seems a though the variables are being honored by by the other commands

#

Using filename: /config/www/tmp/snapshot_uvc_front_door_{{ timestamp }}.jpg
Creates ' snapshot_uvc_front_door_.jpg '

craggy mica
#

If a set a variable in an automation, should I be able to use it anywhere in the automation?

data: message: |- {{ now().strftime("%r on %m-%d-%Y") }} Inside: **{{ states('sensor.ac_garage_temp') | round(1) }}°F** Outside: **{{ states('sensor.tempest_station_temperature') | round(1) }}°F** Closed For: **{{ (now().replace(microsecond=0) -states('input_datetime.garage_door_closed') | as_datetime | as_local) }}** ![image]( {{snapshot_url}} ) [Link](/lovelace/garage) title: Garage Door - OPENED action: notify.persistent_notification

hollow nymph
#

I think in theory yes.
Share the whole automation?

craggy mica
#

`action:

  • variables:
    timestamp: "{{ now().strftime('%Y%m%d_%H%M%S') }}"
    snapshot_filename: "/config/www/tmp/snapshot_uvc_front_door_{{ timestamp }}.jpg"
    snapshot_url: "/local/tmp/snapshot_uvc_front_door_{{ timestamp }}.jpg"

  • choose:

    • conditions:
      • condition: trigger
        id:
        • OPEN
        • CLOSED
        • ERROR
        • NOT-UPDATING
          sequence:
      • service: camera.snapshot
        target:
        entity_id: camera.uvc_front_door_high_resolution_channel_insecure
        data:
        filename: "{{ snapshot_filename }}"`
#

` - service: notify.mobile_app_joes_iphone
data:
title: >-
Mailbox - {%- if states.binary_sensor.mailbox_door.state == 'off' %} CLOSED
{%- elif states.binary_sensor.mailbox_door.state == 'on' %} OPENED
{%- else %} ERROR {%- endif %}
message: >-
{{ now().strftime("%m-%d-%Y - %r") }}

            Status: {%- if states.binary_sensor.mailbox_door.state == 'off' %} Closed
                    {%- elif states.binary_sensor.mailbox_door.state == 'on' %} Opened
                    {%- else %} Error {%- endif %}
          data:
            attachment:
              content-type: jpeg
              url: "{{ snapshot_url }}"`
craggy mica
hollow nymph
#

I am not sure.

#

It looked good to me.

#

I thought I vaguely remember reading something in the past about a weirdness with camera.snapshot templates, but I don't remember the exact detail.

craggy mica
#

I moved the snapshot to a script and stored the file name in a helper and this is working:
`alias: Snapshot-Mailbox
sequence:

  • variables:
    timestamp: "{{ now().strftime('%Y%m%d_%H%M%S') }}"
    snapshot_filename: snapshot_uvc_front_door_{{ timestamp }}.jpg
    snapshot_path: /config/www/tmp/{{ snapshot_filename }}
  • data:
    value: "{{ snapshot_filename }}"
    target:
    entity_id: input_text.snapshot_mailbox_filename
    action: input_text.set_value
  • data:
    filename: "{{ snapshot_path }}"
    target:
    entity_id: camera.uvc_front_door_high_resolution_channel_insecure
    action: camera.snapshot
  • wait_template: >-
    {{ snapshot_filename in
    state_attr('camera.uvc_front_door_high_resolution_channel_insecure',
    'entity_picture') }}
    timeout: "00:00:01"
    mode: single`
#

I will have to try just using the variables in an automation outside of the camera.snapshot and see if the values are stored.

#

The camera.snap works great, just using variables to create the snapshot with a unique filename and putting that file name in the notifications isn't working.

craggy mica