Just went through the Alexa Smart Home setup and got stuck a "discover Devices"

Hi Folks,

I am running a synology box with Home Assistant Core as a docker container, I have a few other containers supporting this.

I set up remote access using DuckDNS. I wasnt sure if this was necessary since I already had the synology based access. Either way its done now.

I then needed to get to the right port. My understanding is that synology uses 443, so the way around this is to create a reverse proxy.

For this I have:

External:
HTTPS
Hostname.duckdns.org
Port 8443

Destination:
HTTP
192.168.XXX.XXX
Port 8123

I am now able to go to my hostname.duckdns.org:8443 and I get access to my homeassistant login page.

I set up a custom user for alexa and tested the login (its administrative use, not sure if that matters).

In Security on Synology I set up a certificate for my hostname.duckdns.org through lets encrypt.

With all this done, I went through the Alexa Smart Home setup shown here:

A few things to note, in account linking, I used the following:
Authorization URI:https://hostname.duckdns.org:8443/auth/authorize
Access Toke URI: https://hostname.duckdns.org:8443/auth/token
Authentication Scheme: Credentials in request body

In Lambda, the test event results in:

Execution result: succeeded(logs)
Details
The area below shows the result returned by your function execution. Learn more about returning results from your function.
{
  "statusCode": 200,
  "body": "\"Hello from Lambda!\""
}

No Devices are shown specifically, but it seemed like it connected fine.

I previously ran Emulated Hue so I know the devices work.

Any help would be appreciated.

when you run a discovery test do items show up in the JSON?

Not sure exactly what you mean, but if I got to AWS console and run the test command from there it gives me this:

START RequestId: 877d9d72-c0e3-437b-a692-44feb622c268 Version: $LATEST
END RequestId: 877d9d72-c0e3-437b-a692-44feb622c268
REPORT RequestId: 877d9d72-c0e3-437b-a692-44feb622c268	Duration: 1.33 ms	Billed Duration: 100 ms	Memory Size: 128 MB	Max Memory Used: 47 MB	Init Duration: 107.85 ms

No this is tested on the llamda page. It’s where you use the temporary long lived access token. There is a test button where you can test functionality. I believe the default is testing discovery.

Sorry that is the same as what I posted above. From the lambda page it says " Execution result: succeeded" but its not finding devices.

Then you aren’t sending the proper request. What JSON is being sent when you click test?

this is what I would expect, probably a different message ID

{
  "directive": {
    "header": {
      "namespace": "Alexa.Discovery",
      "name": "Discover",
      "payloadVersion": "3",
      "messageId": "1bd5d003-31b9-476f-ad03-71d471922820"
    },
    "payload": {
      "scope": {
        "type": "BearerToken"
      }
    }
  }
}

Copied and pasted from my test config:

{
  "directive": {
    "header": {
      "namespace": "Alexa.Discovery",
      "name": "Discover",
      "payloadVersion": "3",
      "messageId": "1bd5d003-31b9-476f-ad03-71d471922820"
    },
    "payload": {
      "scope": {
        "type": "BearerToken"
      }
    }
  }
}

and when you expand detail, there should be a JSON response.

Please let me know if anything shouldnt be showing…

Yeah, that’s not right. You should see a response from home assistant. Seems like you may have missed a step.

What code did you paste into your lambda_function?

Are you in the US or elsewhere? Myself and others have tried to set this up but it wouldn’t work as we were in Europe. Been posted on here a few times but devs didn’t seem bothered.

Don’t know if it was ever fixed but I went back to Haaska which still works perfectly.

Okay Petro, you totally figured it out there. When I pasted in the code, I didnt click save and I thought I had done that correctly but it was still the original code.

I repasted lambda_function and its correctly receiving devices now. Time to try alexa skill. Thank you!

Okay, corrected.

Still not discovering devices. Here is the optput:

{
  "event": {
    "header": {
      "messageId": "4e6da379-745a-443d-b5d8-1288dc8d21f5",
      "name": "Discover.Response",
      "namespace": "Alexa.Discovery",
      "payloadVersion": "3"
    },
    "payload": {
      "endpoints": [
        {
          "capabilities": [
            {
              "interface": "Alexa.TemperatureSensor",
              "properties": {
                "proactivelyReported": true,
                "retrievable": true,
                "supported": [
                  {
                    "name": "temperature"
                  }
                ]
              },
            
ETC ETC ETC ETC ETC (removed for sanity)
        }
      ]
    }
  }
}

And the log output:

START RequestId: be7318e8-6fa2-4fb8-acfa-d917d26d979a Version: $LATEST
[DEBUG]	2020-04-27T16:56:14.273Z	be7318e8-6fa2-4fb8-acfa-d917d26d979a	Event: {'directive': {'header': {'namespace': 'Alexa.Discovery', 'name': 'Discover', 'payloadVersion': '3', 'messageId': '1bd5d003-31b9-476f-ad03-71d471922820'}, 'payload': {'scope': {'type': 'BearerToken'}}}}

/var/runtime/urllib3/connectionpool.py:1004: InsecureRequestWarning: Unverified HTTPS request is being made to host 'XXXXXXXX.duckdns.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning,
END RequestId: be7318e8-6fa2-4fb8-acfa-d917d26d979a
REPORT RequestId: be7318e8-6fa2-4fb8-acfa-d917d26d979a	Duration: 382.15 ms	Billed Duration: 400 ms	Memory Size: 128 MB	Max Memory Used: 51 MB	Init Duration: 151.32 ms

It’s seeing devices. That first endpoint is one. So it should be working now.

BUUUUUUUUT

If you have media_players, they may make the discovery fail. So remove them from configuration. Here’s what my configuration looks like and you can use it as a guide.

Basically list out what you want to send to alexa in include_entities. Then give them special unique ‘Alexa only’ names in the entity_config section

alexa:
  smart_home:
    filter:
      include_entities:
        - fan.bonus_room_bedroom
        - fan.bonus_room_office
        - fan.master_fixture
        - light.bonus_room_bedroom_fixture
        - light.bonus_room_bedroom_recessed
        - light.bonus_room_entrance
        - light.bonus_room_office_fixture
        - light.bonus_room_office_recessed
        - light.dining_room_chandelier
        - light.game_room_bulb
        - light.game_room_bulb_2
        - light.hallway
        - light.kitchen_cans
        - light.kitchen_island
        - light.living_room
        - light.master_bathroom_cans
        - light.master_bathroom_sink
        - light.master_closet
        - light.master_fixture
        - media_player.dining_room_speakers
        - media_player.living_room_speakers
        - switch.basement_cans
        - switch.basement_stairs
        - switch.dining_room_hutch
        - switch.disney_plus
        - switch.downstairs
        - switch.echo_through_receiver
        - switch.floating_outlet_switch
        - switch.foyer
        - switch.game_room_outlet
        - switch.game_room_switch
        - switch.game_room_window
        - switch.garage_cans
        - switch.garage_entry
        - switch.garage_workbench
        - switch.hbo_now
        - switch.hulu
        - switch.inside
        - switch.kitchen_cabinet
        - switch.kitchen_outlet_above_fridge
        - switch.kitchen_outlet_above_microwave
        - switch.kitchen_pantry
        - switch.laundry
        - switch.living_room_window
        - switch.master_bathroom_fan
        - switch.master_nightstand_left
        - switch.master_nightstand_right
        - switch.netflix
        - switch.outside
        - switch.outside_porch
        - switch.passenger_sconce
        - switch.prime_video
        - switch.ps4
        - switch.roku
        - switch.sconces_garage
        - switch.sconces_main_entrance
        - switch.switch
        - switch.tv
        - switch.upstairs
        - switch.xbox_one
    entity_config:
      fan.bonus_room_bedroom:
        name: Bonusroom Fan
      fan.bonus_room_office:
        name: Office Fan
      fan.master_fixture:
        name: Master Fan
      light.bonus_room_bedroom_fixture:
        name: Bonusroom Fixture
      light.bonus_room_bedroom_recessed:
        name: Bonusroom Cans
      light.bonus_room_entrance:
        name: Bonusroom Hallway
      light.bonus_room_office_fixture:
        name: Office Fixture
      light.bonus_room_office_recessed:
        name: Office Cans
      light.dining_room_chandelier:
        name: Chandelier
      light.game_room_bulb:
        name: Bulb 1
      light.game_room_bulb_2:
        name: Bulb 2
      light.hallway:
        name: Hallway
      light.kitchen_cans:
        name: Can Lights
      light.kitchen_island:
        name: Island Lights
      light.living_room:
        name: Living Room Light
      light.master_bathroom_cans:
        name: Master Can
      light.master_bathroom_sink:
        name: Master Sink
      light.master_closet:
        name: Master Closet
      light.master_fixture:
        name: Master Light
      media_player.dining_room_speakers:
        name: Dining Room Speakers
      media_player.living_room_speakers:
        name: Living Room Speakers
      switch.audio_1:
        name: Audio One
      switch.audio_2:
        name: Audio Two
      switch.basement_cans:
        name: Basement Cans
      switch.basement_stairs:
        name: Basement Stairs
      switch.dining_room_hutch:
        name: Hutch Lights
      switch.disney_plus:
        name: Disney Plus
      switch.downstairs:
        name: Downstairs
      switch.echo_through_receiver:
        name: Echo
      switch.floating_outlet_switch:
        name: Echo Outlet
      switch.foyer:
        name: Foyer Lights
      switch.garage_cans:
        name: Garage Fixtures
      switch.garage_entry:
        name: Entry Lights
      switch.garage_workbench:
        name: Workbench
      switch.hbo_now:
        name: HBO Now
      switch.hulu:
        name: Hulu
      switch.inside:
        name: Inside
      switch.kitchen_cabinet:
        name: Cabinet Lights
      switch.kitchen_outlet_above_fridge:
        name: Kitchen Outlet Above Refrigerator
      switch.kitchen_outlet_above_microwave:
        name: Kitchen Outlet Above Microwave
      switch.kitchen_pantry:
        name: Pantry Lights
      switch.laundry:
        name: Laundry
      switch.living_room_window:
        name: Living Room Outlet
      switch.master_bathroom_fan:
        name: Master Bath Fan
      switch.master_nightstand_left:
        name: Nightstand Left
      switch.master_nightstand_right:
        name: Nightstand Right
      switch.netflix:
        name: Netflix
      switch.game_room_outlet:
        name: Game Room Light
      switch.game_room_switch:
        name: Game Room Switch
      switch.game_room_window:
        name: Game Room Outlet
      switch.outside:
        name: Outside
      switch.outside_porch:
        name: Outside Outlet
      switch.passenger_sconce:
        name: Passenger Sconce
      switch.prime_video:
        name: Prime Video
      switch.ps4:
        name: Playstation
      switch.roku:
        name: Roku
      switch.sconces_garage:
        name: Garage Sconces
      switch.sconces_main_entrance:
        name: Main Sconces
      switch.switch:
        name: Switch
      switch.tv:
        name: Cable
      switch.upstairs:
        name: Upstairs
      switch.xbox_one:
        name: Xbox One

EDIT: That goes in your configuration.yaml

Hrmm. No Media Player in config.

I was hoping it would detect entities by itself. But it seems like I have to manually add them? Bummer, but acceptable

No you don’t. This is just how I filter my environment. I have thousands of items and I only want a few to go to alexa.

By default everything is sent to Alexa. But that doesn’t mean it’s sent correctly or usable. I’ve seen issues recently with a few devices so it’s worth looking into filtering it down.

You do have to manually discover devices in alexa. That requires you to click the discovery button or tell her to discover crap.

Any advice on getting SSL working? Doesnt appear that Amazon bleieves I have it, but I did everything I was supposed to.

The big thing I dont understand is why its showing the devices in the test but the actual skilll wont.

Could it be due to using port 8443 instead of port 443? I thought that synology had issues if I forwarded 80 or 443 because it uses those ports.

Have you tried the Nabu Casa trial? Makes setting this up super easy. Might be worth trying and then paying the $5 / month if you like it.

As I said before. There are entities that break the discovery process on ALEXAs side. You have to filter things and find out what is causing the problem.