"and" statement as an automation trigger

I’m trying to trigger an automation based on a sensor value AND an input_boolean state. The idea is that a given value AND a certain input_boolean would trigger the automation. So far, I have tried about 6-8 different syntax variations on:

  trigger:
  - platform: template
    value_template: "{{ states('sensor.meat' > '86') and states('input_boolean.cooking_smoking_pork' == 'on') }}"
  action:
  - data:
      message: Meat is Done
      title: Maverick ET-732
    service: notify.mobile_app_iphone

Ideally, I’d like to use an if statement that allowed me to trigger the automation based on the user defined input_booleans. So, it would also trigger the automation if ‘input_boolean.cooking_grilling_steak’ == ‘on’ AND ‘sensor.meat’ > ‘120’ … as an example.

All of the above variations of the above syntax have failed to trigger the automation.

By including both entities in the trigger and in the conditions you effectively make the automation AND the triggers. i.e. the automation will trigger on either entity but both conditions have to be true for the action to be executed.

  trigger:
  - platform: numeric_state
    entity_id: sensor.meat
    above: 86
  - platform: state
     entity_id: input_boolean.cooking_smoking_pork
     to: 'on'
  condition:
  - condition: numeric_state
    entity_id: sensor.meat
    above: 86
  - condition: state
    entity_id: input_boolean.cooking_smoking_pork
    state: 'on'
  action:
  - data:
      message: Meat is Done
      title: Maverick ET-732
    service: notify.mobile_app_iphone
1 Like

…or by getting the template correct…

  trigger:
  - platform: template
    value_template: "{{ states('sensor.meat')|int > 86 and is_state('input_boolean.cooking_smoking_pork' , 'on') }}"

then i would need to write a new automation for every variation on the input_boolean. For example, cooking_smoking_pork, cooking_grilling_steak, and cooking_grilling_chicken would all need a separate automation. I’m trying to use a single automation for the different input_booleans and associated “doneness” temps.

That triggered it; I figured it was a syntax issue. Still new to templates. Cheers!

1 Like