You’re using an old-style group which the documentation doesn’t show it supports grouping sensors.
Even if you use the new-style group (which does support sensors) you have to specify how you want to group the sensor values (see: Sensor Groups). For example, if you choose to show the average, it won’t be useful for your intended application (report when one of the sensors falls below 20%).
In addition, your Numeric State Trigger uses a value_template to get the value from the sensor’s battery attribute. Does each one of the three sensors report battery level in an attribute named battery or in its state property?
I suggest you forego using a group and simply list the entities directly in the Numeric State Trigger. Alternately, use a Template Trigger that monitors all sensors whose entity_id ends with the word “_battery”. Either way, it’s important that you confirm where each sensor stores the battery level (in its state or in attributes).
automation:
- alias: Notifica batteria bassa sensori zigbee
trigger:
platform: numeric_state
entity_id:
- sensor.aqara_temp_studio_battery
- sensor.pir_bagno_battery
- sensor.pir_disimpegno_battery
below: 20
action:
- service: notify.mobile_app_le2123
data_template:
title: "Batteria Bassa"
message: "Il livello della batteria è al di sotto del 20% per il sensore {{ trigger.to_state.attributes.friendly_name }}."
-14 14:17:26.258 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'dict object' has no attribute 'to_state' when rendering 'Il livello della batteria è al di sotto del 20% per il sensore {{ trigger.to_state.attributes.friendly_name }}.'
2024-01-14 14:17:26.258 ERROR (MainThread) [homeassistant.components.automation.notifica_batteria_bassa_sensori_zigbee] Notifica batteria bassa sensori zigbee: Error executing script. Error for call_service at pos 1: Error rendering data template: UndefinedError: 'dict object' has no attribute 'to_state'
2024-01-14 14:17:26.260 ERROR (MainThread) [homeassistant.components.automation.notifica_batteria_bassa_sensori_zigbee] Error while executing automation automation.notifica_batteria_bassa_sensori_zigbee: Error rendering data template: UndefinedError: 'dict object' has no attribute 'to_state'
Here’s a way to trigger the automation’s Numeric State Trigger without waiting for one of the three sensors to decrease below 20.
You can temporarily “force” the sensor’s value to be less than 20.
Go to Developer Tools > States
Find sensor.pir_bagno_battery in the list and click it.
Scroll to the top of the page where all of the sensor’s properties are displayed in a form.
Take note of its current State value (perhaps make a copy of it). It should currently be above 20 in order for the test to work.
Change the value to 19 or anything less than 20.
Click the Set State button.
That should be sufficient to trigger the automation’s Numeric State Trigger.
Optionally, use the same technique to set the sensor’s value back to the original temperature. Otherwise, simply wait for the sensor’s integration to update the sensor’s value.