Lambda function

Hello I’m trying to ask Alexa something like where my wife is, I have owntracks setup and have it tracking but, I’m having some troubles and just wondering if I have to make a new lambda function on every new skill I create. This is the first one I’m trying to do as it is was well documented.
Thankyou

I actually did this without using HA but it was difficult to setup. (I used a free service which converts longitude and latitude to cross streets to make it understandable)

A much simpler way to it, if you are ok with saying “Alexa, turn on wife locator”, is to get Alexa (through Emulated Hue) to turns on a HA switch which runs TTS through your media player (not Alexa as it can’t be pushed yet)

I’m trying to do something like this first,

I’m trying the first one because it was set I only needed to change some names to match my setup, and after that, I also want to have alexa tell me the temperatures from some sensors I have around the house, I followed this

But was getting connection errors, on both and was wondering, If I Had to make a new Lambda function on every skill I made.

I think you want to make one skill called Home Assistant and make several intents, like the activate scene intent or locate intent or the temperature intent as in the example.

the temp intent works by saying “Alexa, ask Home Assistant for the temperature of sensor”

@RobDYI Ok I understand that [quote=“RobDYI, post:4, topic:14682”]
I think you want to make one skill called Home Assistant and make several intents, like the activate scene intent or locate intent or the temperature intent as in the example.
[/quote]

And I already have HA linked with a Skill and Lambda, So my question is do I have to make another Lambda Function to add another Skill or can I use the Lambda Function I already have.

Sorry, I don’t know the answer, I created one skill called Home assistant and many intents to control HA and provide info. Not sure how to create another skill to control HA.

@RobDYI ok have you added to your intents since you did it the first one or did you do them all at once.

I did the example then added my own intent to it after.

Intent Schema

{
  "intents": [
    {
      "slots": [
        {
          "name": "User",
          "type": "AMAZON.US_FIRST_NAME"
        }
      ],
      "intent": "LocateIntent"
    },
    {
      "slots": [],
      "intent": "WhereAreWeIntent"
    },
    {
      "slots": [
        {
          "name": "Scene",
          "type": "Scenes"
        }
      ],
      "intent": "ActivateSceneIntent"
    }
  ]
}

Sample Utterances

ActivateSceneIntent activate {Scene}
LocateIntent Where is {User}
LocateIntent Where’s {User}
LocateIntent Where {User} is
LocateIntent Where did {User} go
WhereAreWeIntent where we are

@RobDYI Ok mine looks close to yours did you use HTTPS or Lambda services, to get your to work

I used https

OK that’s the difference between yours and mine I thought I had to use Lambda services again. Could you help me or point me in the right direction to do https I’m running duckdns and letsencrypt. I’m not sure how to get the proper setup with https.
Thank you

@RobDYI This is part I’m not sure on From the link above Alexa / Amazon Echo

Endpoint:

https
https://YOUR_HOST/api/alexa?api_password=YOUR_API_PASSWORD

Is this my end point to HA and my HA password or Do I have to make a Alexa API and link it to that

Thank you

That is correct. Make sure that you setup SSL, I use Lets Encrypt and duckdns.org as described in the HA instructions. Once you have your SSL setup and HA running with Alexa part added to your configuration.yaml, go to Alexa dev tool and to HA skill and test the SSL and your end point and your HA skill. You should have all green before testing on your Echo.

OK so if I get this right mine should look like this If my password to HA was 123456

https://MYDUCKDNSNAME.duckdns.org/api/alexa?api_password=123456

I dont have to change the /alexa?api_password to anything?

Thank you

nope, you got it.

https://MYDUCKDNSNAME.duckdns.org/api/alexa?api_password=123456

OK then I’m still doing something wrong I’m getting the same Error as I did with the Lambda function

ERROR: The remote endpoint could not be called, or the response it returned was invalid.

all green check marks all the way including test,

I read somewhere about special characters in the passwords, Mine has one could that be stopping it.

Can you login through https?

To test your api, try this in a browser (change sensor.time to a sensor you have setup if you don’t have time)

https://MYDUCKDNSNAME.duckdns.org:8123/api/states/sensor.time?api_password=123456

i get this in the browser

{“attributes”: {“friendly_name”: “Time”, “icon”: “mdi:clock”}, “entity_id”: “sensor.time”, “last_changed”: “2017-03-31T17:38:21.134415+00:00”, “last_updated”: “2017-03-31T17:38:21.134415+00:00”, “state”: “10:38”}

if that works, its probably your Alexa: setup in the configuration.yaml.

OK I got back, But with out the port :8123

{“attributes”: {“friendly_name”: “STUDY TEMP”, “unit_of_measurement”: “\u00b0F”}, “entity_id”: “sensor.study_temp”, “last_changed”: “2017-03-31T20:44:17.465198+00:00”, “last_updated”: “2017-03-31T20:44:17.465198+00:00”, “state”: “83.66”}

So I get the Response back So I would think that the communication is OK, So it may be in my alexa.yaml

So I put it straight in my configuration.yaml file and get the same ERROR

One Question on the Certificate for NA Endpoint:there are 3 options to choose from I picked the first one

My development endpoint has a certificate from a trusted certificate authority

Is that the right one to use?
others are

My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority

and

I will upload a self-signed certificate in X.509 format.

It depends on how you setup your SSL, I used Lets Encrypt which acts as trusted authority so I use

  • My development endpoint has a certificate from a trusted certificate authority

you might have self signed which you then will use

  • I will upload a self-signed certificate in X.509 format

When I put “test” in the Alexa app skill test. i get “There was an error calling the remote endpoint, which returned HTTP 500 : Internal Server Error” What do you get?

You might want to try the examples first to test it isn’t your alexa.yaml setup

I get, “The remote endpoint could not be called, or the response it returned was invalid.”

I setup mine just like the examples until I get it working the only change is the name of my devices

here is my configuration

alexa:
  intents:
    WhereAreWeIntent:
      speech:
        type: plaintext
        text: >
          {%- if is_state('device_tracker.dee', 'home') and
                 is_state('device_tracker.cathy', 'home') -%}
            You are both home, you silly
          {%- else -%}
            Cathy is at {{ states("device_tracker.cathy") }}
            and dee is at {{ states("device_tracker.dee") }}
          {% endif %}

    LocateIntent:
      action:
        service: notify.notify
        data_template:
          message: The location of {{ User }} has been queried via Alexa.
      speech:
        type: plaintext
        text: >
          {%- for state in states.device_tracker -%}
            {%- if state.name.lower() == User.lower() -%}
              {{ state.name }} is at {{ state.state }}
            {%- elif loop.last -%}
              I am sorry, I do not know where {{ User }} is.
            {%- endif -%}
          {%- else -%}
            Sorry, I don't have any trackers registered.
          {%- endfor -%}
      card:
        type: simple
        title: Sample title
        content: Some more content