Media dirs and their paths

I don’t get along with HA’s media paths management and need some advice, please:
(and btw. the documentation about media_paths and media_source is not that intuitive to me)

My webcam is taking a snapshot on motion detection and saves it under /media/tapo/last_motion.jpg, which opens in the media browser via Media Sources / Local Media / tapo.
My Samba share path looks like this: \192.168.1.252\media\tapo\last_motion.jpg

My confguriation.yaml:

homeassistant:
  allowlist_external_dirs:
    - "/media/tapo"
  media_dirs:
    media: "/media/tapo"

When I set up a picture card or send a notification with attachment to my mobile with the path \media\tapo\last_motion.jpg then no imaging is showing up. So what the heck am I doing wrong?

After trawling through various threads about this topic I finally got it to work by moving the tapocam folder inside the www and adjusting the paths accordingly

snapshot/record service → absolute path ( /config/www/tapocam/last_motion.jpg )
notify service → local path ( /local/tapocam/last_motion.jpg)

homeassistant:
  allowlist_external_dirs:
    - /config/www/tapocam
  media_dirs:
    local: /config/www/

Glad you work it out.

I have a nice automation regarding this that might help you further. I use IP Webcam for android and it exposes also entities for light (turns on the phone light) and also night vision. In my hall where the main door is, i also have an LED strip attached to furniture that illuminates the room. I build an automation that is using all these with the following logic:

  1. when the door or window opens (trigger)
  2. if we are away or on vacation (conditions)
  3. Actions:
    a) Turn on the hall furniture LED
    b) If its after sunset, it will also turn on the phone light to further illuminate the room
    c) If its after sunset, it will activate the night vision
    d) It will take a snapshot from the camera
    e) It will send the snapshot to my phone
    f) After one minute it will turn off the lights and night vision

Here is the automation yaml:

alias: Security - Camera Motion
description: ""
trigger:
  - type: opened
    platform: device
    device_id: 3676cb415ce79ee6e4a170779bcff40f
    entity_id: binary_sensor.main_door_sensor_ias_zone
    domain: binary_sensor
  - type: opened
    platform: device
    device_id: 6aa9081478a7972d231bc71c1fbeec3b
    entity_id: binary_sensor.lr_window_sensor_ias_zone
    domain: binary_sensor
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: input_select.home_status
        state: Away
      - condition: state
        entity_id: input_select.home_status
        state: Vacation
action:
  - type: turn_on
    device_id: 6b4816ffd6c0ba41f7a96caf577f7c7d
    entity_id: light.hall_furniture_local
    domain: light
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.192_168_100_7_torch
  - if:
      - condition: sun
        after: sunset
    then:
      - service: switch.turn_on
        data: {}
        target:
          entity_id: switch.192_168_100_7_night_vision
    else:
      - service: switch.turn_off
        data: {}
        target:
          entity_id: switch.192_168_100_7_night_vision
  - delay:
      hours: 0
      minutes: 0
      seconds: 3
      milliseconds: 0
  - service: camera.snapshot
    data:
      filename: /config/www/s.jpg
    target:
      entity_id: camera.192_168_100_7
  - service: notify.mobile_app_michael
    data:
      message: Motion Detected at Home
      data:
        image: /local/s.jpg
      title: Security Notification
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: 6b4816ffd6c0ba41f7a96caf577f7c7d
    entity_id: light.hall_furniture_local
    domain: light
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.192_168_100_7_torch
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.192_168_100_7_night_vision
mode: single

as you can see, i have placed the screenshot in /config/www/ and then for it to be sent i set the path as /local/filenume.extension

The “local” folder is actually the “www” folder inside the config directory.

Hope this helps
Kind Regards
M

1 Like