Download video from MQTT Sensor

I apologize if this is in the wrong spot, but I am truly at my wits end.

My setup

  • HA on docker 2024.11.3

I have a custom bash script that publishes data to the following mqtt topics:

  • homeassistant/sensor/cam1/motion
  • homeassistant/sensor/cam1/image
  • homeassistant/sensor/cam1/video

“motion” is a unix epoch timestamp. “image” and “video” are https URLs.

sensor config in configuration.yaml

mqtt:
  sensor:
    - name: Zmodo Cam1Last Motion
      state_topic: "homeassistant/sensor/cam1/motion"
      device_class: timestamp
      value_template: '{{ as_datetime(value) }}'
    - name: Zmodo Cam1Video
      state_topic: "homeassistant/sensor/cam1/video"
      value_template: '{{ value }}'
  image:
    - name: Zmodo Cam1 Image
      url_topic: "homeassistant/sensor/cam1/image"

What is working

  • Automation listens on “motion” and sends push notification
  • Push notification sends the screenshot using image: /api/image_proxy/image.zmodo_cam1_image

What I want

Is to send the video URL to my device. ← This does not work!

I have tried basically everything to no avail. At the very least, how can I use the “Download” integration to download this file then use the media endpoint and pass that into my push notification?

Relevant logs

When attempting to download from URL:

2024-12-03 12:14:02.753 ERROR (MainThread) [homeassistant.components.automation.zmodo_cam1_push_notify] Zmodo Cam1 Push Notify: Error executing script. Invalid data for call_service at pos 2: invalid url for dictionary value @ data['url']
2024-12-03 12:14:02.753 ERROR (MainThread) [homeassistant.components.automation.zmodo_cam1_push_notify] Error while executing automation automation.zmodo_cam1_push_notify: invalid url for dictionary value @ data['url']

Screenshot of downloader in automation

Any tips/tricks are greatly appreciated in advance!!! Thank you all.

I did figure this out (of course after asking for help).

  1. Make sure you have the downloader integration setup (mine is setup to /media/downloads)
  2. Create a new script (I manually added it to scipts.yaml)
  get_cam1_video:
    sequence:
      - service: downloader.download_file
        data_template:
          url: "{{ states('sensor.zmodo_cam1_video') }}"
          filename: motion_cam1.mp4
          overwrite: true
  1. Edit/Create your automation
  2. Add a building block, Sequence, add get_cam1_video script, add notify with data section like
video: /media/local/downloads/motion_cam1.mp4