I’m trying to create an automation that turns on my filter in my 3d printer if certain types of filaments are being used. This is what I have right now. It works if I have “Bambu ASA” as the state which corresponds directly to what the entity reports. I would like it to match any filament with ASA or ABS in its name.
alias: Printer VOC Filter
description: ""
triggers:
- trigger: state
entity_id:
- sensor.x1c_00m09d482801714_current_stage
to: printing
conditions:
- condition: state
entity_id: sensor.x1c_00m09d482801714_active_tray
state: "*ASA"
actions:
- type: turn_on
device_id: 893164f096465f4f27e79608a74619f7
entity_id: d78c831c814c35427fb932695ebb11fa
domain: switch
mode: single
in the conditions section, add an ‘OR’ building block. Put your existing state in the OR condition, and create a copy of that to make your second condition. Once triggered, either condition being true will satisfy the automation in order to run the actions.
I don’t want to have to add “Filament A ASA”, “Filament B ASA” and so on. I’m looking to start it for anything that has ASA in the state. I’m trying to use wildcard variables like * to include all filaments with (‘whatever filament’ ASA) in the state.
condition: template
value_template: |
{{ states('sensor.x1c_00m09d482801714_active_tray') is search('ASA') }}
HA Doc - Templating - Regular Expressions
If you need a more specific search you can use Python Regex operators.
1 Like
Only the template (the part on line 3 in your screenshot) goes in the “Value template*” field.
That should have been obvious, thanks. Working as intended now.
{{ states('sensor.x1c_00m09d482801714_active_tray') is search('ASA|ABS') }}