Entity id as input_select name

I have 100+ temperature sensors.
There are 3 kind of alerts I can configure for each of these sensors (Heater, Cooler, Freezer).
I use drop down entity that has the same entity name as the sensor to set the kind of alarm I want (Heater, cooler, Freezer).
I don’t want to create 3 automations for each sensor I have. So I try to add every sensor in one automation, but it needs to trigger only if the input_select of the triggered sensor is set to a specific state. (I dont want a Cooler to be triggered by freezer temperatures).

Here is my code :

alias: Alerte Cooler
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.1046_temperature
      - sensor.1069_temperature
      - sensor.1103_temperature
      - sensor.1120_temperature
      - sensor.1121_temperature
      - sensor.1122_temperature
      - sensor.1101_temperature
    below: 2
  - platform: numeric_state
    entity_id:
      - sensor.1046_temperature
      - sensor.1069_temperature
      - sensor.1103_temperature
      - sensor.1120_temperature
      - sensor.1121_temperature
      - sensor.1122_temperature
      - sensor.1101_temperature
    above: 26
condition:
  - condition: state
    entity_id: input_select.1101
    state: Cooler
action:
  - service: notify.sendgrid
    metadata: {}
    data:
      title: Alerte de température!
      message: >-
        La température du conteneur Cooler {{ trigger.to_state.name }} est à {{
        trigger.to_state.state }}°C. 
mode: single

Now I can only set the condition section to a specific sensor. I would like it to be set dynamically to fit the entity name of the triggered sensor like this :

condition:
  - condition: state
    entity_id: input_select.{{ trigger.to_state.name }}
    state: Cooler

But it dosent work.

I’m a beginner, but I really want to be able to set 3 different kinds of alarm on each 100+ sensor without needing to create 300+ automations…

Thanks in advance.

The entity_id option of the state condition does not support templates. Use a template condition.

condition:
  - condition: template
    value_template: "{{ is_state(trigger.to_state.entity_id, 'Cooler') }}"

Or in shorthand notation:

condition:
  -  "{{ is_state(trigger.to_state.entity_id, 'Cooler') }}"

Since you’ve already set up triggers related to each type, you can just give your trigger an ID that matches the type you need it to match from the Input select to send the notification.

The following assumes that the entity IDs follow a set convention wherein sensor.1046_temperature goes with input_select.1046_temperature.

alias: Alerte Cooler
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.1046_temperature
      - sensor.1069_temperature
      - sensor.1103_temperature
      - sensor.1120_temperature
      - sensor.1121_temperature
      - sensor.1122_temperature
      - sensor.1101_temperature
    below: 2
    id: Cooler
  - platform: numeric_state
    entity_id:
      - sensor.1046_temperature
      - sensor.1069_temperature
      - sensor.1103_temperature
      - sensor.1120_temperature
      - sensor.1121_temperature
      - sensor.1122_temperature
      - sensor.1101_temperature
    above: 26
    id: Heater
condition:
  - condition: template
    value_template: |
      {% set select_state = states( trigger.to_state.entity_id | replace('sensor.', 'input_select.') ) %}
      {{ select_state | lower == trigger.id | lower }}
action:
  - service: notify.sendgrid
    data:
      title: Alerte de température!
      message: >-
        La température du conteneur {{ trigger.id }} {{ trigger.to_state.name }} est à {{
        trigger.to_state.state }}°C. 
mode: single

mmm… not sure to understand. Tried it but it doesn’t works.
Here are the conditions I try to do :

IF (the temperature of any temperature sensor is below 2 OR above 25) AND that the dropdown list corresponding to the same number as the triggered temperature sensor is “cooler”.
THEN send me a notification with the sensor number, it’s temperature and the dropdown list state.

hope it’s clearer like this.
Thanks again.

You have given the following condition:

But, you have not provided an example of how they correspond.

In my post I stated:

If that is not correct, you need to tell us what is correct.

How did you test it? What didn’t happen that was expected? What do the automation’s debugging traces show?