Include area for alexa voice command

Hi together,
I’m currently setting up my first HA instance and so far everything is working pretty good. Alexa integration works but I am wondering if I can take it a little further. Currently I have two switches included in the alexa smart home configuration. Both are lights and both are in the 'living room" area. Lets assume one is called “Floor lamp”, I now want to tell alexa to switch on the floor lamp in the living room. If I add another entity called “Floor Lamp” in the “Bed Room” area I want to say switch on the floor lamp in the bed room. Currently the only solution I would know would be to name the entities “Floor lamp in the living room” and “Floor lamp in the bed room”. Is there a way to do it the other way and include the HA area? This is my alexa configuration (german names):

smart_home:
  filter:
    include_entities:
      - switch.tasmota1
      - switch.tasmota2
  entity_config:
    switch.tasmota1:
      name: "Floor lamp in the living room"
      description: "Floor lamp in the living room"
      display_categories: LIGHT
    switch.tasmota2:
      name: "Floor lamp in the bed room"
      description: "Floor lamp in the bed roomr"
      display_categories: LIGHT

Thank you!

No. Amazon hasnt added the necessary logic to target a specific device by area like that with the exception of targeting specific device types (light, thermostat in some cases) based on the group the Echo device that heard the command belongs to or switching an entire group.

And all of this is controlled on the Alexa side.

Its also why every device in my home that I may use with voice is named [roomname] [whatever my wife calls the device] so in your case… Master Bedroom Floor Lamp. (I actually have a master bedroom floor lamp its a light group with three zigbee bulbs: master bedroom floor lamp bottom, middle, and top)

I have a few exceptions, for instance, TV is the main television in the family room, and Xbox is the Xbox attached to that TV but pretty much everything else uses room-device.

You have to get very specific with planning naming of devices when voice activation in larger installs come in to play.

Yes, maybe… If you are only looking for on/off control, you can use the Alexa Media Player custom integration.

You will need:

  1. A “last_called” sensor

  2. A pair of room-aware scripts. For just a few lamps I would use a static dictionary-based script instead of messing around with more complicated dynamic templates:

Dictionary-based Scripts Example
# "Alexa, turn on floor lamp"
alexa_turn_on_floor_lamp:
  sequence:
    - service: homeassistant.turn_on
      data_template:
        entity_id: >-
          {%- set room = area_name(states("sensor.last_alexa"))-%}
          {%- if room == "Living Room" -%}
            switch.tasmota1
          {%- elif room == "Bed Room" -%}
            switch.tasmota2
          {% endif %}

# "Alexa, turn off floor lamp"
alexa_turn_off_floor_lamp:
  sequence:
    - service: homeassistant.turn_off
      data_template:
        entity_id: >-
          {%- set room = area_name(states("sensor.last_alexa"))-%}
          {%- if room == "Living Room" -%}
            switch.tasmota1
          {%- elif room == "Bed Room" -%}
            switch.tasmota2
          {% endif %}
  1. A pair of routines in the Alexa app that will run your scripts when you use your trigger phrases.

If you want brightness and/or color control, I would see if you can do it using room groups in the Alexa app. It can be done with the process above using an Actionable notification approach, i.e. when you say “Alexa, turn on the floor lamp” she will ask “What Brightness?”… but that can get tiresome very quickly.

1 Like