Can Nabu Casa get the Alexa device name?

I would like to be able to say, “Alexa, fans” and have the ceiling fans in the room where the Echo device is located turn on (if they are off) or off (if they are on). I’m pretty sure I have enough coding skill to write a Home Assistant script to do that, but I need to know if Nabu Casa would let me know which of my several Echo devices is being used so that I can somehow pass that information on to Home Assistant to figure out which fans to turn on/off.

If you are using Nabu and the Alexa app - possibly. Simply put the fans and lights in the room with Alexa (in the Alexa App) and everything works.

As in “Alexa turn on the lights” only turns on the lights in the room. I don’t have any proper fans to test it with so it may not work, but it is worth a try…

Nabu Alexa does also have things you can listen to - I use this to turn the lights warm white when someone asks to “turn on the lights” - so in this instance if the living room lights turn on (because the app knows which alexa it is) she runs this automation :

alias: Alexa - Living Room White
description: ""
trigger:
  - platform: event
    event_type: alexa_smart_home
    event_data:
      request:
        namespace: Alexa.PowerController
        name: TurnOn
        entity_id: light.living_room_lights
condition: []
action:
  - service: mqtt.publish
    data:
      qos: "2"
      retain: false
      payload: >-
        {   "color": {     "r": 255,     "g": 255,     "b": 255   },  
        "brightness": 1 }
      topic: zigbee2mqtt/Living Room Lights/set
  - service: mqtt.publish
    data:
      qos: "2"
      retain: false
      payload: >-
        {   "color": {     "r": 255,     "g": 255,     "b": 255   },  
        "brightness": 1 }
      topic: zigbee2mqtt/Living Room Spots/set
  - service: light.turn_on
    data:
      rgb_color:
        - 255
        - 255
        - 255
      brightness: 0
    target:
      entity_id: light.tasmota_uplighter
  - service: script.living_room_lights_white_50
    data: {}
mode: single

Maybe that will help. I am sure there must be more events Alexa triggers.

What you’re looking for is the last called Alexa attributes available from the Alexa Media Player integration in HACS. It’s not available in the default Alexa integration

1 Like

Simply put the fans and lights in the room with Alexa (in the Alexa App) and everything works.

As in “Alexa turn on the lights” only turns on the lights in the room. I don’t have any proper fans to test it with so it may not work, but it is worth a try…

@Neil_Brownlee, Unfortunately, the “lights” functionality does not extend to fans. The fans are wifi, so the Alexa knows about them, but it doesn’t seem to know what a “fan” is.
As for your code, what kind of event is it triggering off of? My best guess is when the Alexa turns on the living room lights?

@NathanCu That might be a good place to get the information from. I’m kind of asking before I bite the bullet on Nabu Casa. I tried building my own skill with AWS etc, but I started floundering when I tried to combine DuckDNS, nginx, and trusted users. Servers aren’t my strong point.

Nabu Casa access ahs nothing to do with this.

the Alexa default integration does not provide the informaiton you seek, this one does - by way of the attribute I mentioned.

The HACS repo is here: custom-components/alexa_media_player: This is a custom component to allow control of Amazon Alexa devices in Home Assistant using the unofficial Alexa API. (github.com)

It goes through the installation - which does not mention nabu - or your method of crossing the boundary at all if I remember.

Once you have that - someone has already solved for your use case:

So have fun. :slight_smile:

Thanks! I’m not 100% sure whether the one you linked to is using HA to run an Alexa Routine, or using an Alexa Routine to run HA. It looks like maybe… both?

Ha triggers Alexa. When you set this up you will get a sensor that updates with the last Alexa device that heard something. The ‘last called’ use that in automation on the HA side