I want to make an automation with multiple entities and every entity have 10 attributes.
If trigger.entity_id is for getting which entity has been triggered the automation, what should I use to find out which attribute from the entitty has triggered the automation?
This will give you a list of attributes that changed.
{% set ns = namespace(changed=[]) %}
{% for k, v in trigger.to_state.attributes.items() if trigger.from_state.attributes.get(k) is not none and v != trigger.from_state.attributes.get(k) %}
{% set ns.changed = ns.changed + [ k ] %}
{% endfor %}
{{ ns.changed }}
Be advised that the Core development team have been guiding integration developers, and users, to avoid creating sensors with multiple attributes (especially if the attributes contain non-static data).
There are several reasons for this guidance and you have encountered one of them (can’t easily tell which attribute was responsible for triggering the State Trigger).
For example, the Tasmota integration models a power-monitoring plug using multiple entities, a switch, a sensor for power, another sensor for energy, another for total energy, etc. Each entity serves a specific function, thereby making it easy for use with a trigger and to record and display its history.