Getting the correct file -

Hi.

I have an automation set up to send me a notification with an url to the a video from the security camera when sensor detects movement outside when we’re not home.

action:
      - service: camera.logi_circle_livestream_record
        data:
          entity_id: camera.outside
          filename: !secret camera_file
          duration: '15'
      - delay: '00:00:30' #Make sure the movie is saved before sending the notification
      - service: notify.pushbullet
        data:
          title: 'bla bla
          message: 'bla bla bla'
          data:
            url: !secret camera_url

The !secret camera_file is the https://myserver.com/the_camera_file.mp4 from the camera. And the same path is used in the notification url.

My question is: Can I set the filename to something unique (eg. movie_date_and_time_stamp.mp4) and then pass this unique name to the notification? Then I could send multiple notifications with unique movies.

You could move the actions into a script, and then call the script from the automation, passing the script the filename you want to use. E.g.:

script:
  record_notify:
    sequence:
      - service: camera.logi_circle_livestream_record
        data_template:
          entity_id: camera.outside
          filename: "https://myserver.com/{{ filename }}"
          duration: '15'
      - delay: '00:00:30' #Make sure the movie is saved before sending the notification
      - service: notify.pushbullet
        data_template:
          title: 'bla bla'
          message: 'bla bla bla'
          data:
            url: "https://myserver.com/{{ filename }}"
automation:
  - alias: blah
    ...
    action:
      service: script.record_notify
      data:
        filename: movie_date_and_time_stamp.mp4

If you still want to keep the https://myserver.com/ part in the secrets.yaml file, then it gets a bit more complicated.

1 Like

Thank you! Worked like a charm :slight_smile: Yes, the secret part will be an issue, no big deal and I will deal with that later.