Help with limited templates restrictions

Hello brains trust.

I am wanting to modify a large community blueprint for Frigate Camera notifications to make configuring it easier for new users and also allow multiple cameras to be configured in one automation.

My issue stems from the trigger variable not allowing most templates i’ve tried.
This is the working yaml currently for one camera

trigger_variables:
  input_camera: !input camera
  camera: "{{ input_camera | regex_replace('^camera\\.|_\\d+$', '') }}"
  mqtt_topic: !input mqtt_topic

I’m wanting to allow users to select multiple cameras and I want to be able to leverage the new attribute “camera_name” that the frigate integration provides on these camera entities.

This works perfectly in the template editor but is prohibited in limited templates.

{% set input_camera = ['camera.front','camera.car_port', 'camera.doorbell'] %}
{% set cameras = input_camera|expand|map(attribute='attributes.camera_name')|list %}
trigger_variables:
  input_camera: !input camera
  camera: "{{input_camera|expand|map(attribute='attributes.camera_name')|list}}" #Expand not allowed)
  mqtt_topic: !input mqtt_topic

I’m seeking ideas on how to get the list of camera names.
The subsequent trigger i’m going for looks like this to complete the picture if necessary

  - platform: mqtt
    topic: "{{mqtt_topic}}"
    payload: "{{True}}/new"
    value_template: "{{ camera|select('in', value_json['after']['camera'])|list|length>0 }}/{{ value_json['type']}}"
    id: frigate-event

Hello SgtBatten,

The best way to combat limited trigger problems is trigger more generally, IE include more stuff, and then use the conditions to narrow it down to what you really want. You have full access to everything after the trigger pops including the entity that triggered.

This way you can use the logic you know works. Just trigger on the topic, then template using that to get the camera.

Thanks, got it working as you suggested

1 Like