Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Can no longer select payload version 2 - Skill can't connect #102

Open
ghost opened this issue Dec 18, 2017 · 20 comments
Open

Can no longer select payload version 2 - Skill can't connect #102

ghost opened this issue Dec 18, 2017 · 20 comments

Comments

@ghost
Copy link

ghost commented Dec 18, 2017

Hi, I went to set this up today and am not having much luck.

My lambda is connecting OK, but my skill is not. There are a coupls of things that I'm unsure about.

Firstly, when I am on the developer console and go to the test simulator, if I select manual JSON I appear to have to select a region at the bottom left corner from a drop down list. But this list is completely unpopulated, so I can't select anything.

Also, and perhaps more significantly, under skill information, I can only select Payload Version v3. Since v2 is now deprecated and I am unable to select it. This seems unfortunate because according to several threads (e.g #49 and #86 ), you need to select version 2.

Can anyone help? Can i force v2 somehow?

Thanks,

James

@ghost
Copy link
Author

ghost commented Dec 18, 2017

I've now verified that I have most of the set up done correctly. I can go into the Alexa app and find my skill and I can link my amazon account. I beleive that means I've done all the "Log in with Amazon" and the "Account Linking" stuff correctly in theg set up.

I also get a positive response when I run a test in the lambda which seems to indicate that everything's working.

I do not get a positive responses running "make test" but I think that may be because my AWS CLI configuration is wrong.

Ultimately, (ignoring the result of "make test") it appears the problem is the communication between the skill and the lambda. And I believe this is due to the differences between v2 and v3 payloads. Can anyone help?

@ghost
Copy link
Author

ghost commented Dec 18, 2017

Looking at this a bit more; the differences between v2 and v3 are not insignificant. I'm not a coder/programmer, so don't think I can pick this up myself, but hopefully someone can :-)

I did have a look, and think I can change the format of the Discover response to have the correct names in it (e.g, ApplianceID becomes endpointID), but much of the other stuff to do with discovering what services and how those responses are made is such a large change that it's beyond me!

@wladwnt
Copy link

wladwnt commented Dec 19, 2017

You still can select v2 with one trick. The Selection v2 is just deactivated in html. If you use firefox, use right click (mouse) on the v2 select box, tehn in the pop-up menu select "examine element (Q)" (or similar item, I have it in german, not sure how it is written in english). Then you can edit html code. You have to find disabled="disabled" as a tag property and delete it. Than you can select v2 :)

@wladwnt
Copy link

wladwnt commented Dec 19, 2017

The best solution, of course, is to update haaska to v3. Hope the author will do it.

@malcolmrigg
Copy link

malcolmrigg commented Dec 19, 2017

You might want to take a look at this: https://home-assistant.io/blog/2017/12/17/introducing-home-assistant-cloud/
Although I've just noticed that this won't be free either...

@ghost
Copy link
Author

ghost commented Dec 19, 2017

@wladwnt I was so excited to read a suggestion that I took the following steps on my phone.

  • remoted in to my router with a VPN
  • then connected a SSH session to my raspberry pi.
  • I then used Etherwake to wake up my Windows PC and waited for it to turn on.
  • I opened Chrome, searched for "download firefox" and then downoloaded firefox
  • browsed to the Developer Console in firefox.
  • managed to right click and inspect the element.
  • deleted the bit of code you mentioned
  • selected version 2.
  • the save button wasn;'t available but when I clicked next, the developer console prompted me to save.
  • Tada, I'm sorted! It's working. Thanks very much!

@malcolmrigg - it's because I can't use Home Assistant Cloud that I was inspired to get this going.

@ghost
Copy link
Author

ghost commented Dec 19, 2017

Also, I should say - thanks very much @wladwnt !

@user0x01
Copy link

Dankeschön

@bitglue
Copy link

bitglue commented Jan 21, 2018

Looks like home-assistant implements some part of the smart home API now. I'd guess this means the Lambda function can be much simpler?

@cbrherms
Copy link

@bitglue that's related to home assistant cloud. The paid for feature that's currently in beta and at the moment only available for testing by people who use American Amazon accounts. Doesn't currently work for those of us UK English.
It does technically the same as haaska, plus potentially more in future, but for those of us who want to use a none paid for option haaska will do the job.
There is someone working on getting this functional with V3 here. It's looking like it's almost fully implemented tbf

@bitglue
Copy link

bitglue commented Jan 22, 2018

Home assistant cloud is just a dumb proxy. It's purely a convenience function: all the Smart Home API logic is in that smart_home.py file.

The cloud component publishes the protocol over a websocket, which the Home Assistant Cloud servers proxy to Amazon. I'm just a stupid low-level programmer so I don't know about these websocket things, but it took all of 10 lines of code to expose the same API with an HTTP POST. Then the Lambda function reduces to:

def event_handler(event, context):
    config = Configuration('config.json')
    if config.debug:
        logger.setLevel(logging.DEBUG)
    ha = HomeAssistant(config)

    return ha.post('alexa_smart_home', event, wait=True).json()

I've just finished the POC, and Alexa discovered my devices and I flipped a few lights on and off. I'll put a bow on this, with PRs to home-assistant to add the necessary HTTP API, and one to Haaska to use that (and update some of the documentation). I don't see much point in implementing the v3 Smart Home payload in Haaska since it's already in home-assistant, and there it's well tested and has support of core developers.

@mike-grant

@cbrherms
Copy link

Thankyou for opening my eyes!
The term look before you leap springs to mind.
Actually hadn't looked in to HA's implementation of cloud yet. Deeming it irrelevant for the time being as they'd not made it available in the UK yet.

@waternexus
Copy link

waternexus commented Jan 22, 2018

@bitglue Could you share the code for your PoC and the config?

Do you post to http://HASSIP:8123/api/alexa_smart_home or http://HASSIP:8123/alexa_smart_home?

@bitglue
Copy link

bitglue commented Jan 22, 2018

https://gist.github.com/bitglue/66ca023b3c3c1a5b267bdd1d9b3ee48f

I'm working on some PRs, once I've made this cleaner.

@waternexus
Copy link

Awesome, hopefully you'll submit the PRs before Saturday so they could potentially be merged into HA 0.62.

You should post something on the Discord, some other devs might want/be willing to help you.

@cbrherms
Copy link

Do you think HA will merge a PR that bypasses their paid for method though?

@GreenTurtwig
Copy link

GreenTurtwig commented Jan 22, 2018

@bitglue Works fine! Good work. 🐈
35228466-b7db448e-ff88-11e7-8e2c-295b2dcc209c

@bitglue
Copy link

bitglue commented Jan 22, 2018

Do you think HA will merge a PR that bypasses their paid for method though?

We'll see. It's not as if I'm giving away some secret sauce here. If they wanted to force people into using the paid solution they could have easily implemented the API outside home-assistant (like haaska) and kept it private.

@mike-grant
Copy link

I actually really like this idea of exposing it in the way that you have. If this pull request makes it into HA then it would be better for the longer term.

@bitglue
Copy link

bitglue commented Jan 22, 2018

Here are the corresponding changes to Haaska: #109

A bit rough around the edges: certainly some more cleanup and simplification can happen, but it works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants