Hi there,
trying to learn this system and would appreciate a pointer or where I can find the answer to this. I’ve already looked at all the questions that came up related to this topic.
I used the ring automation example for triggering saving the video when the door bell is rung and tried to figure out how to make it work across all the motion detect entities of all the ring cams and then save the respective mp4 from the URL for the specific entity where motion was detected.
For the ring cam named front, the binary sensor for motion is called binary_sensor.front_motion and basically all the binary sensors for the cams follow this pattern (binary_sensor.[front|backyard|trashcondo]_motion)
This is the trigger:
alias: Save motion detected videos
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.front_motion
to: 'on'
condition: []
which then gets expanded across multiple binary sensors like:
entity_id:
- binary_sensor.front_motion
- binary_sensor.backyard_motion
Below is the basic action definition for single camera front:
service: downloader.download_file
data:
url: "{{ state_attr('camera.front', 'video_url') }}"
subdir: >-
{{state_attr('camera.front', 'friendly_name')}}/{{ now().strftime('%Y.%m')
}}
filename: >-
{{state_attr('camera.front', 'friendly_name')}}-{{
now().strftime('%Y-%m-%d-at-%H-%M-%S') }}.mp4
If I instead define this automation for a bunch of motion triggers as shown above, how do I extract the correct atrribute from the entity that triggered?
What I want to happen once parsed is the following:
if binary_sensor.front_motion transitions to on, url: "{{ state_attr(‘camera.front’,‘video_url’) }}
if binary_sensor.backyard transitions to on, url: "{{ state_attr(‘camera.backyard’,‘video_url’) }}
How do I derive camera.front or camera.backyard depending on whether binary_sensor.front_motion or binary_sensor.backyard_motion was triggered?
Bonus question: Is there a less verbose way of identifying a specific set of binary_sensors than just enumerating them as above?
Thanks,
Christian