Configure Alexa / Sensor / Scripts to call room Temperature

Hey there,

I have several aquara Temp Sensors around the House an sometimes i want to ask Alexa aubout the temperature an humidity in an specific room.
The problem is that my sensors named like “temperature livingroom”

So, if I wanna ask alexa, I have to say: “Alexa, whats the temperature of temperature Livingroom?”
which is noch very elegant.
It would be better to ask “Alexa, whats the temperature in the Livingroom?”

I found a solution an google which doesnt work for me. And if I had to be honest, I don’t understand how it works.

platform: template
sensors:
  last_alexa:
    unique_id: *** hier eine unique ID eintragen (VSCode Kontextmenu -> generate UUID) ***
    value_template: >
        {%- for group in states.media_player | groupby('state') -%}
          {%- for entity in group.list -%}
            {%- if is_state_attr(entity.entity_id, 'last_called', true) %}
              {{ entity.entity_id }}
            {%- endif -%}
          {%- endfor -%}
        {%- endfor -%}
alias: wie ist die Temperatur im Wohnzimmer
sequence:
  - service: notify.alexa_media
    data_template:
      target:
        - '{{ states.sensor.last_alexa.state }}'
      data:
        type: tts
        method: speak
      message: >
        {% set alexa_text = [ "Die Temperatur im Wohnzimmer beträgt ",
                              "Im Wohnzimmer sind ", 
                              "Im Moment sind im Wohnzimmer " ] | random %}
        {{ '{} {} Grad Celsius.'.format( alexa_text, states('Multisensor.Esszimmer')) }}  
mode: single
alexa:
  smart_home:
    filter:
      include_entities:
        - script.wie_ist_die_Temperatur_im_Wohnzimmer

The question is, is there a better, easier Solution.

It would be awesomne if someone give me some tipps and Ideas.

Definitely check out the Room Aware examples on the AMP wiki.

I don’t know if this is better or easier, but the method I use is to set up a routine in the Alexa app which calls my script. This allows you to set a few different voice trigger phrases. I keep mine generic like “Alexa, what’s the temperature in here”, “Alexa, what’s the room temperature”, “Alexa, room temperature”…I think you’re allowed 7 phrases per routine.

The script handles the room awareness logic. In the following script I use a sensor groups that contains all my room thermometers. It’s possible to derive that information using templates, but you end up doing as much or more maintenance when you do it that way.

alias: Notify - Alexa Room-Aware - Temperature
sequence:
  - service: notify.alexa_media_last_called
    data:
      message: >
        The temperature in the {{ echo_area }} 
        is {{temp}} degrees Celsius.
      data:
        type: tts
mode: single
variables:
  echo_area: "{{ area_name(states('sensor.last_alexa')) }}"
  temp: >
    {{ state_attr('sensor.indoor_thermometers', 'entity_id')
    | select('in', area_entities(echo_area)) | map('states') | first }}
3 Likes