Check files are created and size is > x

Hi

I have some ip cameras recording on cifs share mounted in HA under /media. Unfortunately sometimes the cameras stop recording or start splitting the recordings in unwanted sized.

I’d like to have an automation confirm that a file has been created, under a specific path, in the last hour and such file has a size greater than X Mb.

I was thinking on using Folder Watcher - Home Assistant in conjunction with File Size - Home Assistant to set a sensor switch to on (e.g.)

Anyone can recommend a better route or have different idea to approach this need?

thanks!

the folder structure camera recordings use is the following:

  • Recordings
    • Camera1
      • dayX
        • hoursY
          • fileZ
    • Camera2
      • dayX
        • hoursY
          • fileZ

I’m struggling with folder watch in recognising if a file is created by the same camera (or at least under the same portion of path)?

The other issue is that File Size - Home Assistant requiring defining the name of the file upfront?

I can run the following command to find out if a file is created

find /media/Summary/CC-Balcone/ -name "*.mp4" -mmin -5 -size +10000000

just need to figure out how to set the state of a switch or sensor based on output…

at the end I had to use a bit of bash

  - platform: command_line
    name: "CC-Balcone Recording"
    command: 'find /media/Summary/CC-Balcone/ -name "*.mp4" -mmin -60 -size +100000 -exec echo "found" \; | head -n 1'
    device_class: running
    payload_on: "found"
    payload_off: ""
    scan_interval: 360

command is looking for files mp4 written in the last 60 mins and with a size over 100mb - it will display ‘found’ for any occurrence - but since payload_on need an exact match, I’m using | head -n 1' to catch only the first line

This is the result:

image