I’m new to Home Assistant so I don’t have a lot of reference yet.
I’m using a trigger from a motion sensor to snapshot some camera feeds to local files, and then send an email with the snapshots.
I have a list of actions where the first one takes snapshots from three cameras and then uses a jinja reference to write each to a unique filename, but then in the next list item where I dispatch the email, I’m stuck referring to the full image paths.
How do I reference the list of filenames I created in the first action?
You can’t create a list with a template since a template will only output a single string. Even if you put line feeds and dashes in the template output, it will just still be a single string that happens to contain line feeds and dashes. This is a common mistake. Remember, YAML processing happens first, way before the template is rendered.
So I would suggest sticking with your first solution. However, I don’t think you can use {{ entity_id.name }}. I think it should be:
This is a common mistake. Remember, YAML processing happens first, way before the template is rendered.
Oh wow, okay. I thought for sure that the templating engine chewed through the file, rendered YAML, and then the YAML processing occurred at the end. That makes things a lot clearer. Thanks!
However, I don’t think you can use {{ entity_id.name }}. […] Or, if you really want to remove the “camera.” part … {{ entity_id.replace('camera.', '') }}
When I originally used entity_id, I got filenames like snapshot1.[dvr1_camera1_stream].jpg, or possibly even weirder names… I don’t quite recall. Adding .name yielded my desired result. Out of curiosity, is there a way to browse that namespace?
Wow, that entity_id variable is very different from what I expected. And the doc page doesn’t explain it properly either. It’s actually a Camera Python object! Or more importantly, a Python object of a class derived from the Camera class. So apparently when you do {{ entity_id.name }} it’s invoking the object’s name property. Wow!!
FWIW, the name property will usually show itself as the entity’s friendly_name attribute. May not be what you want here. So maybe: