Transform a trigger with multiple entities as a condition does not work

Hello all, I’m a new user of Home Assistant. Great job!

I’m trying to generate a trigger that will be used at noon every day to check battery level for many devices. I first generated this code that is accepted by the “check config” button:

    - alias: "Battery too low"
      trigger:
        platform: numeric_state
        entity_id: 
          - sensor.Mailbox
          - sensor.Freezer
          - sensor.Toilette_1er_Spill
          - sensor.Toilette_2eme_Spill
          - sensor.Laveuse_Spill
          - sensor.Fournaise_Spill
          - sensor.Salon_Smoke
          - sensor.Passage_1er_Smoke
          - sensor.Passage_2eme_Smoke
          - sensor.Fournaise_Smoke
        value_template: '{{ state.attributes.vbat }}'
        above: 0.0
        below: 2.8
      action:
        - service: notify.mailer1
          data_template:
            message: "Battery too low: {{ trigger.state.name }}"
            title: "[Home] Battery too low: {{ trigger.state.name }}"

As we can’t add an “at:” to numeric_state and that there is no way to have an “and” conditional in a trigger (or is it??), I then tried to modify it such that it is fired at noon using a condition:

- alias: "Battery too low"
  trigger:
    platform: time
    at: '12:00:00'
  condition: 
    condition: numeric_state
    entity_id: 
      - sensor.Mailbox
      - sensor.Freezer
      - sensor.Toilette_1er_Spill
      - sensor.Toilette_2eme_Spill
      - sensor.Laveuse_Spill
      - sensor.Fournaise_Spill
      - sensor.Salon_Smoke
      - sensor.Passage_1er_Smoke
      - sensor.Passage_2eme_Smoke
      - sensor.Fournaise_Smoke
    value_template: '{{ state.attributes.vbat }}'
    above: 0.0
    below: 2.8
  action:
    - service: notify.mailer1
      data_template:
        message: "Battery too low: {{ trigger.state.name }}"
        title: "[Home] Battery too low: {{ trigger.state.name }}"

But I get the following message from the “check config” button:

Invalid config for [automation]: value should be a string for dictionary value @ data['condition'][0]['entity_id']

Why is this not possible??
Thanks for your help!

Guy

check this thread that might save you from re-inventing the wheel:

1 Like

I use this script and call it every couple hours. It does what you want.

#####################################
zwave_battery_check:
  alias: Zwave Battery Check

  sequence:
    - condition: template
      value_template: >-
        {%- set battery_alert_threshold = 40|int -%}
        {{ states.zwave | selectattr('attributes.battery_level', 'defined') | selectattr('attributes.battery_level','<', battery_alert_threshold ) | list | length >= 1 }}

    - service: script.notify_all_engines
      data_template:
        title: "ZWAVE Low Battery"
        who: "john"
        message: >-
          {%- set battery_alert_threshold = 40|int -%}
          {%- set low_batteries = states.zwave | selectattr('attributes.battery_level', 'defined') | selectattr('attributes.battery_level','<', battery_alert_threshold ) | map(attribute='name') | list | join(', ') -%}
          Low batteries in the following devices: {{ low_batteries }}