Speech Parser script to extract entity Id information into readable form for Alexa or Google Assistant TTS

# get dummy light brightness
        v = self.get_state(self.trigger, attribute = "brightness")
# error checking
        if v == None :
            self.debug("Invalid trigger value {}".format(v))
            self.turn_off(self.trigger)
            return
# convert brightness 0-255 to %
        value = round((v/255*100))
        self.debug("Trigger value= {}".format(value))

So, I haven’t read this whole thread, how does “Alexa have I left the doors open” end up getting sent to HA without her responding like an idiot?

Yes thats cool but this way I have to switch it to appdeamon, and for now I want to keep it in ha.

I will probably switch later to your script.

Ok how can i do that? is there a command for that like “round”

easiest way is to integer divide ( double division sybmol ).

{{ 255 // 10 }}

thanks I will try, but the code above from @lonebaggie seems like he doesn’t do that because he rounds… hm

But to get from 1% to the value 2 I don’t devide.
Or from 10 % to 25.
or from y % to x

x = 255/100 * y
x= 2.55 * y

I tried ** in the template but that doesn’t do the same as //.

So how can I cut this with a multiplication?

just gotta reorganize the math. percentages always divide by 100

{{ (255 * 1) // 100 }}

ok thanks.

I pretty sure know that it shows integers in the amazon app but in fact sends floats.
The reason why I think this is it is possible to drag the slider a little bit arround and stay at a certain value.

Is there a way to fill in a number there and not draging the slider?

Quick update:

  1. X% in Alexa app will always be X% no matter how you use the slider (so no floats as I thought before). This is good, as this makes it reliable
  2. It does indeed not round, it truncates.

Works with the suggestions from above ( // ).

Thanks!

Alexa Home only reports 0-100% as BRI. Home Assistant and Node-Red expect 0-255, so translation is necessary.

So, how does this work? As I said, I have only found Alexa Home which is simply returns on, off, or bri. I would love to be able to script Alexa to respond to other commands. Like, “Alexa what is the basement temperature?”, or could it even let me ask “Alexa, where is kim?” and determine it she is at work or driving using Life 360?

the alexa app on android or iphone supports alexa routines

read the title :slight_smile:

So, you aren’t going to tell me?
How do you get an Alexa routine into Home Assistant?

how about reading the first post from this topic?

edit: but nowadays you can also implement the alexa mediaplayer component.

Nowhere did the prior posts mention an Alexa Mediaplayer Component. (I did not realize that there is an Alexa component). We’re obviously talking about two completely different methods of getting an Alexa interface to Home Assistant.

thats right. but at the time this topic was started there was only 1 option.
and just a simple search on the forum brings a lot. (try alexa and you finde the mediaplayer component)

so the answer to your question how to use alexa routines in HA still stands.

  1. read the first post and use that option
  2. find the custom component alexa mediaplayer on the forum and use that option.

@lonebaggie I used your virtual_light template in my configuration.yaml flike so:

light:
  - platform: template
    lights:
      alexa_virtual:
        friendly_name: "Alexa Dummy Light"
        turn_on:
        turn_off: 
        set_level:

It shows up in my entities and has a state of ‘off’. When I ask alexa to discover devices, it doesn’t find it. Am I supposed to expose it in some other way? I’ve exposed emulated hue lights as scripts and the scripts are discovered fine. I’m using the alexa/media_player v0.10.2.

Thanks

See the following

Any issues I will answer on that thread . Keep the help easy to find