Hi everyone,
finally got my voice PE and playing around with the assist feature (i love this).
I’ve discovered soon, that assist always uses the thermostat of an area to determine the temperature. However, i want it to read the normal temperature sensors (e.g. we don’t have a thermostat where we sleep).
I was able to create an intent, which reads the area from the voice command, searches for the first temperature sensors and outputs the temperature – almost perfect. The result would be:
German: “Es ist 19.5 Grad im Wohnzimmer” (English: It is 19.5 Degree in the living room)
How can i read the area where the voice was activated?
e.g. if i talk to my voice assistant PE in the kitchen, i want to give out the kitchen’s temperature.
Any other tips you can give me in my automation?
Cheers and a happy new year of tinkering
alias: Voice - Temperatur im Zimmer
description: ""
triggers:
- trigger: conversation
command:
- Wie warm ist es im {area}
- trigger: conversation
command:
- Wie warm ist es in der {area}
conditions: []
actions:
- set_conversation_response: >-
{% set result = states.sensor
| selectattr('entity_id', 'in', area_entities(trigger.slots.area))
| selectattr('object_id', 'search',
'^(?!.*(schalter|steckdose|strom)).*_temperature$')
| selectattr('state', '!=', 'unavailable')
| map(attribute='state') | list %}
{{ 'Es ist ' + result[0] + ' Grad im ' + trigger.slots.area if result else 'Keine Temperaturangabe gefunden' }}
mode: single
Notes
This searches for all sensors
set result = states.sensor
This searches for all entities in the area specified in the voice command
selectattr('entity_id', 'in', area_entities(trigger.slots.area))
This searches for entities with the name temperature, but removes schalter/steckdose/strom (i don’t want to have the internal temperature of my shelly switches)
| selectattr('object_id', 'search', '^(?!.*(schalter|steckdose|strom)).*_temperature$')
This removes the unavailable entities
| selectattr('state', '!=', 'unavailable')
This outputs the first temperature result if it exists, else “Keine Temperaturangabe gefunden” is there is not temp sensor
{{ 'Es ist ' + result[0] + ' Grad im ' + trigger.slots.area if result else 'Keine Temperaturangabe gefunden' }}