Ok, found the solution myself. If anyone is interested.
The area of the triggering device (e.g. the HA voice PE) can be read via
area_id(trigger.device_id)
To keep one single automation, i’ve added intents with {area} and some without.
This expression then sets the correct area: if the intent (voice command) has an area set, then use it, else use the area of the device.
{%- set area = trigger.slots.area if trigger.slots.area else area_id(trigger.device_id) -%}
This is the entire solution if you are interested
alias: Voice - Temperatur im Zimmer
description: >-
Reads the area from the voice prompt (or the calling device), searches for the first temperature
sensors and outputs the temperature. The result would be in German - Es ist
19.5 Grad im Wohnzimmer
triggers:
- trigger: conversation
command:
- Wie (warm|kalt|heiß|kühl) ist es
- trigger: conversation
command:
- Wie (warm|kalt|heiß|kühl) ist es (im|in der) {area}
conditions: []
actions:
- set_conversation_response: >-
{%- set area = trigger.slots.area if trigger.slots.area else area_id(trigger.device_id) -%}
{% set result = states.sensor
| selectattr('entity_id', 'in', area_entities(area))
| selectattr('object_id', 'search',
'^(?!.*(schalter|steckdose|strom)).*_temperature$')
| rejectattr('state', 'in', ['unavailable','unknown'])
| map(attribute='state') | list %}
{{ 'Es ist ' + result[0] + ' Grad im Raum ' + area if result
else 'Keine Temperaturangabe im ' + area + ' gefunden' }}
mode: single