Alexa and Nabu Casa: how to process voice commands?

Hello,
in order to have the best “connection” between HA and my Alexas I just successfully installed/activated Nabu Casa.

I was hoping to be able now to give Alexa a voice query-command, that would be passed to HA (e.g. to query the current power of the photovoltaic system) and HA would return the result to the Alexa, that received the command.

I have no clue, how to do that.
Any advice or pointer to according documentation would be appreciated. :slightly_smiling_face:

You would need to expose that entity to Alexa either in the Voice Assistants section (Settings>Voice Assistants>Alexa) or in the settings for the entity itself. You can then ask something like “Alexa, what is the value of “[entity name”]”.

However, with that said, entities like power and energy aren’t supported by Alexa. So, I think the only way you could do something like that would be to use the Alexa Media Player integration and use a combination of an Alexa routine along with a script in HA.

1 Like

Thank you for your reply. :slightly_smiling_face:

Is there any chance to identify the Echo device that received the command and then dynamically address the media player entity for that device to send the resply?

Currently I use a button to start an automation that collects the PV values and sends that via media player to an Echo, that is hard-wired in the automation.

Yeah, in Alexa Media Player, there’s a notify.alexa_media_last_called service that allows you to speak to the last device used.

1 Like

Thank you c-i-p.
I almost got it working now.
My voice command triggers an Alexa routine, that sets a helper-switch in HA for 5 sec. That is detected by the automation, that sends information to notify.alexa_media_last_called media player service.

It works for the echo next to my computer. But when I speak to another echo device, the response is always sent to to echo next to my computer, not to the echo I spoke to.

What am I missing?

Add a service call to alexa_media.update_last_called before you issue the TTS, that should correct it.

2 Likes

Show your script or automation or flow. We don’t know what you’re missing if we can’t see it.

Process is call Alexa last called and use it’s output to prime the entity ID for your notification.

Be advised lately reliability seems to have dropped on last called due (i hear rumors on throttling Alexa side? But not sure.) Mines fine for me but I’d say it’s got about a 90% accuracy rate with my 6 echos…

2 Likes

Thank you Bill and Nathan for your replies.

Code looks like:


- id: "1714830448301"
  alias: Sonnentest
  description: Sonnentest
  trigger:
    - platform: state
      entity_id:
        - input_boolean.pv_status
      from: "off"
      to: "on"
  condition: []
  action:
    - service: notify.alexa_media_last_called
      data:
        message: "Die PV-Leistung beträgt {{ states('sensor.sn_3002451053_pv_power') }} Watt."
  mode: single

How would that service call to alexa_media.update_last_called look like?

Update:
According to this page: " As of >= 3.6.0, a notify target will be created automatically notify.alexa_media_last_called."
… it should work in theory (but as Nathan pointed out, reliability is obviously poor).

So next thing to try is the service call, that Bill mentioned.

1 Like

Ok, found it and added these lines of code:

  - service: alexa_media.update_last_called
    data: {}
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500

Seems to work now. :+1:

Update: I found, that you may leave out the hours, minutes and seconds specification and that a delay of 100 ms seems sufficient in my case.