Alexa Routine to Get Device Status?

I have the Home Assistant skill connected with Alexa. Wondering how to get an Alexa routine to reply through Home Assistant on a device’s status?

Something like, “Alexa, what’s the status of the garage door?” whereby the routine will use the Home Assistant skill to get the status of the door sensor device, and to report back on it.

I used to have this ability with Home Seer, where the routine’s ‘Alexa will’ action had asked HomeSeer for the status of the garage door sensor, and Alexa would report it.

Any suggestions appreciated.

1 Like

What i did is created a dum light

then you create a routine that turn on a the dum light to 10%

then have a automation that trigger when the Dum light turn on to 10% dont forget to turn it off after

  - alias: "Alexa: Report"
    id: eb17b04d-ebf8-4652-9d77-63f7d7e4d86d
    trigger:
    - platform: state
      entity_id: light.alexa_virtual
      to: 'on'
    condition:
    action:


   - service: notify.alexa_media
      data_template:
        target: 
          -  '{{ states.sensor.last_alexa.state }}' 
        data:
          type: tts
        message: >-
          {% if (state_attr("light.alexa_virtual","brightness") | int / 255 * 10 ) | int  == 1  %}
            Looking at the Jug  it's   {{ states('sensor.kettle_temperature') }} Degrees ?????
1 Like

Why so difficult? You can directly expose scripts to Alexa.
In the script you just have the TTS response. In Alexa you set up a routine to start the script (listed as a scene) if it detects the phrase.

You could also expose the garage door sensor to Alexa and try to solve it there.

1 Like

That was the workaround I found. HAY IT WORKS FOR ME

also, I can control up to 10 things on that one virtual switch

I built that about 5 Years ago

Here a other one

I say
Alexa: Make me a coffee
she set the virtual light to 2.0

- id: '1667958626523'
  alias: 'Alexa: Coffee Logic'
  description: ''
  triggers:
  - entity_id: input_number.alexa_virtual
    to: '2.0'
    trigger: state
  conditions: []
  actions:
  - entity_id: switch.kettle_power
    action: switch.turn_on
  - data_template:
      where: '{{ states.sensor.alexa_last_playing_name.state }}'
      message: "{{ [
           'If you insist.',
           'I am afraid I can not do that I am kidding,',
           'Leave it to me.',
            'As you wish.',
            'Iam on it.',
            'No Problem.',
            'I think I can handle that.',
            'Working on it now.',
            'Oh, you were talking to me. Let me take care of that.'
            'Why not. It is not like I ever sleep.',
            'I am not even supposed to be here today. But whatever.',
            'You did not say the magic word..  Oh forget it. I will take care of it.',\n            
            'Funny, I was just about to do that.',
            'please  full it after you have done that manual task',
            'There are still terabytes of calculations required before I can.. Oh, whatever.'
                 ]| random
        }}
      voice: alexa
    action: script.speech_engine
  - entity_id: input_boolean.kettle_auto
    action: input_boolean.turn_on
  mode: single
1 Like

Too funny. So she speaks all those phrases?

I created a small script as a test. What is the way an Alexa routing can run a script?

WHEN you say “Alexa check the light”
ALEXA WILL “ask Home Assistant to run light off”

(where ‘Light Off’ is the name of the script) but she doesn’t run it.

2 Likes

Pick a random Visiter think it funny I have this after kettle turn off

- id: kettle hot
  alias: Kettle Just boiled
  triggers:
  - entity_id: switch.kettle_power
    to: 'off'
    trigger: state
  conditions:
  - condition: state
    entity_id: input_boolean.kettle_auto
    state: 'on'
  actions:
  - data_template:
      entity_id: input_boolean.kettle_auto
    action: input_boolean.turn_off
  - data_template:
      where: '{{ states.sensor.alexa_last_playing_name.state }}'
      message: " {{ [  "sorry  don't have hands can't the next part of the job"
       "done my  bit you can do the rest."   ]| random }}
        -}}"
      voice: alexa
    action: script.speech_engine

have the input_boolean.kettle_auto is only trigger if I ask her to make me a coffee so it does go off everytime the kettle is boiled

1 Like

How do you form the Alexa routine to operate a script, though? What is the key to having Alexa do the “ALEXA WILL” to reach through HA to operate the script?

I’m getting a lot closer. The need was to go into the script’s settings and enable the voice assistant and expose the script to Alexa. Then I used Grok to come up with a sample of two conditions for the door, either open or closed. Currently, when the Alexa routine is asked to check the garage door, she will announce whenever it is closed, but not yet when it is open.

Here’s the YAML:

sequence:
  - condition: state
    entity_id: binary_sensor.z_wave_door_window_sensor_window_door_is_open
    state: "off"
  - data:
      message: The garage door is closed.
      target: media_player.kitchen_dot
      data:
        type: tts
    action: notify.alexa_media
  - condition: state
    entity_id: binary_sensor.z_wave_door_window_sensor_window_door_is_open
    state: "on"
  - data:
      message: The garage door is open.
      target: media_player.kitchen_dot
      data:
        type: tts
    action: notify.alexa_media
alias: Check Garage Door
description: ""

Still no solution on how to correctly format the YAML so that it reports on one of two possible statuses (‘on’ or ‘off’). The AI examples I’ve tried do not show valid code.

So, I asked ChatGPT, and apparently a simple solution is just to just ask Alexa if a sensor is open. This doesn’t require an Alexa routine or a script. It will respond with either it is open or closed.