I have a case where I have a few automations triggered by a file created by the folder_watcher component. The conditions to the automations are to check for a string in the trigger.event and then update the file_path of different local_file cameras so that they show their respective image uploads. The issue I’m having is that all the automations keep updating the same camera file_path and not the individual ones. The automations updating the respective input_text states works as it should, but then the two automations that take the input_texts and updates the camera file_paths always updates to camera.kguard_ch03_gate and never to camera.kguard_last_motion. My automations are below: (any help is appreciated)
# This automation checks for ch02 in the data_path of the folder_watcher create event and updates the respective input_text
- id: '1520095552343'
alias: Kguard FTP Input Text Update Latest Motion
trigger:
- event_data:
event_type: created
event_type: folder_watcher
platform: event
condition: []
action:
- condition: template
value_template: "{{ 'ch02' in trigger.event.data.path }}"
- service: input_text.set_value
entity_id: input_text.text_latest_motion
data_template:
value: " {{ trigger.event.data.path }} "
# This automation takes the updated input_text state and updated the camera file_path to the same text
- id: '1520333512343'
alias: Kguard FTP Camera File Path Update Latest Motion
trigger:
- platform: state
entity_id: input_text.text_latest_motion
action:
- service: camera.local_file_update_file_path
entity_id: camera.kguard_last_motion
data_template:
file_path: " {{ states.input_text.text_latest_motion.state }} "
# This automation checks for ch03 in the data_path of the folder_watcher create event and updates the respective input_text
- id: '1520022252378'
alias: Kguard FTP Input Text Update CH03 Motion
trigger:
- event_data:
event_type: created
event_type: folder_watcher
platform: event
condition: []
action:
- condition: template
value_template: "{{ 'ch03' in trigger.event.data.path }}"
- service: input_text.set_value
entity_id: input_text.text_ch03_motion
data_template:
value: " {{ trigger.event.data.path }} "
# This automation takes the updated input_text state and updated the camera file_path to the same text
- id: '1533333519243'
alias: Kguard FTP Camera File Path Update CH03 Motion
trigger:
- platform: state
entity_id: input_text.text_ch03_motion
action:
- service: camera.local_file_update_file_path
entity_id: camera.kguard_ch03_gate
data_template:
file_path: " {{ states.input_text.text_ch03_motion.state }} "
I’ve also tried the following templates, but it gives the same result:
# This works but always updates to ch03_gate
- id: '1520095552343'
alias: Kguard FTP File Path Update Latest Motion
trigger:
- event_data:
event_type: created
event_type: folder_watcher
platform: event
condition: []
action:
- service: camera.local_file_update_file_path
data_template:
entity_id: >
{% if 'ch02' in trigger.event.data.path %}
camera.kguard_last_motion
{% elif 'ch03' in trigger.event.data.path %}
camera.kguard_ch03_gate
{% endif %}
file_path: ' {{ trigger.event.data.path }} '