Giter VIP home page Giter VIP logo

haaska's Introduction

haaska: Home Assistant Alexa Skill Adapter

Join the chat at https://gitter.im/auchter/haaska Build Status

haaska implements a bridge between a Home Assistant instance and the Smart Home Skill API for Amazon's Alexa. It provides voice control for a connected home managed by Home Assistant, through any Alexa-enabled device. Currently, haaska supports the following entity types:

Type On/Off Supported? Dim Supported?
Alerts Yes No
Automations Yes No
Climate Yes Temperature
Cover Yes No
Fans Yes Yes (speed)
Groups Yes No
Input Booleans Yes No
Input Sliders No Yes (value)
Lights Yes Yes
Locks Lock/Unlock No
Media Players Yes Yes (volume)
Scenes Yes No
Scripts Yes No
Switches Yes No

@brusc put together a good video which demonstrates haaska in action, and provides a walkthrough of the setup process.

Note that Home Assistant includes a component (emulated_hue) to communicate with Amazon Echo and Google Home devices. emulated_hue exposes the entities in Home Assistant as Philips Hue lights. This allows basic voice control without the effort of setting up haaska, but its capabilities are limited compared to an Alexa skill and it does not work with every Alexa-enabled device.

Setup

  1. In the config/ directory, copy config.json.sample to config.json and update it. Below is a listing of properties that config.json will accept.

  2. Run make to build a deployable package of haaska. This will generate a haaska.zip file that you'll upload to AWS Lambda (if you're used to docker you can try running make with docker build -t haaska . && docker run -v "$PWD":/usr/src/app haaska

  3. Register with an OAuth provider, such as Login with Amazon.

    • To use the current version of Login with Amazon, you must go to the Developer Console
      • Under "Apps & Services", select "Login with Amazon" (not "Security Profiles")
      • Click "Create a New Security Profile"
      • You can enter anything for the name (which is shown on the login page) and the privacy URL
    • Note the "Client ID" and "Client Secret", as you'll need those later
  4. Create an Alexa skill and Lambda Function by following these instructions (with the modifications noted below).

    • The name of the Alexa skill doesn't matter, but I'd suggest "haaska"
    • The name of the Lambda function does matter; use "haaska", otherwise you'll need to modify the FUNCTION_NAME variable in the Makefile.
    • For "Runtime", select "Python 3.6" as in the example
    • Select "Upload a .ZIP file" for "Code entry type", and upload haaska.zip that you created in step 1.
    • For "Handler", enter haaska.event_handler
    • For "Role":
      • Select "Choose an existing role", and underneath, select lambda_basic_execution if it exists
      • If lambda_basic_execution doesn't exist, select "Create a custom role" instead, and enter lambda_basic_execution as the "Role Name"
    • Leave the rest of the defaults alone, and click "Next"
    • Check "Enable event source"
    • Under the "Account Linking" section:
      • Set Authorization URL to: https://www.amazon.com/ap/oa
      • Set the Client ID to the previously noted value from Login with Amazon
      • Set Scope to: profile
      • Set Access Token URI to: https://api.amazon.com/auth/o2/token
      • Set Client Secret to the previously noted value from Login with Amazon
      • Note the one or more "Redirect URL(s)"
    • There are two properly sized Home Assistant logos in the images/ folder which you can upload to Amazon for use with your skill. Upload both on the "Publishing Information" step of the process.
  5. Go back to Login with Amazon, select "Web Settings" under "Manage" for your security profile, and add each "Redirect URL" from the Lambda function as an "Allowed Return URL".

  6. Send a test event by running make test, which will validate that haaska can communicate with your Home Assistant instance. Note that you must have the AWS CLI and jq installed.

Config Values

Key Example Value Required? Notes
url https://home-assistant.io/demo/ Yes The API endpoint of your Home Assistant instance.
password securepassword Yes The API password of your Home Assistant instance.
ssl_verify mycert.crt No This will be passed as the verify parameter for all requests; see here for options.
expose_by_default true No Whether or not entities should be exposed to Alexa by default. If not specified, this defaults to true.
exposed_domains ["alert", "automation", "climate", "cover", "fan", "garage_door", "group", "input_boolean", "input_slider", "light", "lock", "media_player", "scene", "script", "switch"] No A JSON array of entity types to expose to Alexa. If not provided, the example value is used.
entity_suffixes {"group": "Group", "scene": "Scene"} No A JSON object of entity suffixes to expose to Alexa. If not provided, the example value is used.
debug false No When enabled, the haaska log level will be set to debug. If not provided, this defaults to false.

Usage

After completing setup of haaska, associate the Skill with Alexa by browsing to 'Skills' in the Alexa App (Mobile or Web) and clicking 'Your Skills". Find your skill, click on it, and click enable. Go though the Amazon authentication flow and when finished, click on Discover Devices or tell Alexa: "Alexa, discover my devices." If there is an issue you can go to Menu / Smart Home in the web or mobile app and have Alexa forget all devices, and then do the discovery again. To prevent duplicate devices from appearing, ensure that the emulated_hue component of Home Assistant is not enabled.

Then you can say "Alexa, turn on the office light" or whatever name you have given your configured devices.

Here is the table of possible commands to use to tell Alexa what you want to do:

To do this... Say this...
ON Commands
Alexa, turn on <Device Name>
Alexa, start <Device Name>
Alexa, unlock <Device Name>
Alexa, open <Device Name>
Alexa, boot up <Device Name>
Alexa, run <Device Name>
Alexa, arm <Device Name>
OFF Commands
Alexa, turn off <Device Name>
Alexa, stop <Device Name> (this one is tricky to get right)
Alexa, stop running <Device Name> (also very tricky)
Alexa, lock <Device Name>
Alexa, close <Device Name>
Alexa, shutdown <Device Name>
Alexa, shut <Device Name>
Alexa, disarm <Device Name>
DIM Commands <Position> is a percentage or a number 1-10
Alexa, brighten <Device Name> to <Position>
Alexa, dim <Device Name> to <Position>
Alexa, raise <Device Name> to <Position>
Alexa, lower <Device Name> to <Position>
Alexa, set <Device Name> to <Position>
Alexa, turn up <Device Name> to <Position>
Alexa, turn down <Device Name> to <Position>

To see what Alexa thinks you said, you can see the command history under Menu / Settings / History in the web or mobile app.

To view or remove devices that Alexa knows about, you can go to Menu / Smart Home in the web or mobile app.

(Thanks to @dale3h for originally discovering these!)

Upgrading

To upgrade to a new version, run make deploy

Customization

Sometimes the "friendly name" of an entity in Home Assistant differs from what you'd actually like to call that entity when talking to Alexa. haaska provides a mechanism to define a custom name for an entity that will be used via Alexa. This is achieved by adding your entity to a customize block in your configuration.yaml, and setting the haaska_name key to the desired name.

customize:
  light.some_long_light_name:
    haaska_name: Overhead

If there's an entity you'd like to hide from haaska, you can do that by adding a haaska_hidden tag and setting it to true; e.g.:

customize:
  switch.a_switch:
    haaska_hidden: true

haaska's People

Contributors

auchter avatar bassclarinetl2 avatar blankenshipz avatar dale3h avatar gitter-badger avatar keatontaylor avatar kuruoujou avatar rcloran avatar rhooper avatar robbiet480 avatar stjohnjohnson avatar trisk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

haaska's Issues

Alexa responds with another skill

I have 2 HA scripts called: 'rock music' and 'radio seven'.
When I try to turn them on I got these messages:
rock music: Amazon Music is not supported for this device.
radio seven: Sorry, I can't find a station seven.
Another script called 'greek music' is running fine.
Do you have an idea for a workaround ?

Thanks !

Haaska utterance to 'turn off'

I have 2 switches in HA called 'Kitchen Sonos' and 'Living Room Sonos' which runs the following commands (the below is for Kitchen Sonos):

command_on: "socos play 192.168.0.11"
command_off: "socos pause 192.168.0.11"

The full switch section in configuration.yaml is:

switch:
platform: command_line
switches:
spartacus_control:
command_on: "castnow --address 192.168.0.19 --command space --exit"
command_off: "castnow --address 192.168.0.19 --command space --exit"
friendly_name: Chromecast
kitchen_sonos:
command_on: "socos play 192.168.0.11"
command_off: "socos pause 192.168.0.11"
friendly_name: Kitchen Sonos
living_room_sonos:
command_on: "socos play 192.168.0.12"
command_off: "socos play 192.168.0.12"
friendly_name: Living Room Sonos

The devices appear in the Alexa app under Smart Home > Devices and the value friendly_name: Kitchen Sonos shows the device as 'Kitchen Sonos' I can tell alexa to 'Turn on Kitchen Sonos' and it plays, but cannot say 'Turn off Kitchen Sonos', 'Stop Kitchen Sonos' or any of the other off commands. Running 'socos pause 192.168.0.11' from an ssh session pauses it instantly, as expected. In the Alexa app under History, I can see the 'Turn off Kitchen Sonos' phrase being recorded, but it doesn't do anything.

Any assistance, would be greatly appreciated.

Many thanks in advance.
Matt

Getting sensors status?

Is it possible to get sensors data?
Like door/window sensor, temperature, humidity, light sound and etc?

changed from amazon.com account to amazon.co.uk and now haaska isn't working

As per the title - I have converted my account from a co.uk account to .coma and now haaska isn't working when running make test from the cli I get:

An error occurred (UnrecognizedClientException) when calling the Invoke operation: The security token included in the request is invalid.

In AWS the location is still set to North Virginia.

Minimum steps for changing Home Assistant / haaska password

I have set an easy api password in HA, and now that I have this skill working and HA is exposed to the world, I think it best to change it - however it took me a while to get haaska up and running so just wanted to run the steps past you first.
I looked at the code in the Lamda function on AWS, but couldn't find it any where so i figure i need to re-upload a zip.
Can you please confirm the steps needed to change the HA password and have haaska continue to work?

  1. change the api-password in the configuration.yaml in HA
  2. change the password in haaska/config/config.json
  3. make
  4. Upload and overwrite the zip file in the lambda.
    job done.

GetTemperatureReadingRequest in metric units announces repeating decimal digits

When units are set to metric in the alexa config and a temperature in celsius has a repeating decimal Alexa will announce the repeating decimal up to 10 decimal places. The response should be rounded.

What I also find odd is that rounding is done automatically for temperature responses in fahrenheit, but for fahrenheit it is rounded to an integer value. (Alexa seems to be doing this on its own, not haaska)

Changelog incorrect

Changelog says this:

Entities hidden in Home Assistant (via the hidden attribute) are now hidden from haaska

But #40 was not merged, nor can I find the hidden attribute anywhere in source.

where to find the Ha_passwd??

sorry ,i am the very beginer of HAi want to control all my device handfree
what is the Ha_passwd??is the passwd that i login into my HA or ?if it is,but i havn't set it~how to fill this ?

cover can not be managed by ALexa and haaska

I am trying to manage the cover using Alexa and haaska, but it is not working. Alexa say that " I can not find the cover" or "I can not help with that". The cover is avalable in the list of devices discovered. And it is working using my Home Assistant interface. Could be an internal issue?

lambda keeps timing out

i believe i set everything correctly i have also went back to check everything i also tried
{"header": { "payloadVersion": "1", "namespace": "Control", "name": "DiscoverAppliancesRequest" }, "payload": { "accessToken": "whatever" } }

and i still get that it timed out.. im not really sure where to begin to look at

Unable to import module 'lamda_function'

Worked through the written instructions as well the link youtube video, deleting everything and readding. The skill shows up in the alexa app but doesn't discover anything. I get the same error when testing in Lamda and from make test. I also confirmed I can access home assistant externally.

$ make test
{
"errorMessage": "Unable to import module 'lambda_function'"
}
null
Makefile:38: recipe for target 'test' failed
make: *** [test] Error 1

Thanks,
Mark

How to control media players with haaska?

My media player (samsung smart tv) is visible in home assistant web interface - I can pause/play, increase/decrease volume. I can't control it with alexa.

Haaska is working since I am able to turn on and off various lights, and turn off the tv.

What are the supported alexa commands for media players?

Cryptographic token generation for removing many getting started steps

One of the things I really want is to give more users access to the cool features of haaska in a way that would be substantially easier for them to set up. Which by far the hardest part of setting up haaska is the getting the amazon login, alexa skill, and lambda stuff set up correctly.

All these steps could be avoided if we did the following:

  1. Submit the HAASKA Smart Home Skill to amazon for publishing.

  2. Generate the token by encrypting the user credentials. (hostname, port, ha password)

  3. Queries to haaska will be forwarded to the appropriate ha install based on decryption of the token.

This seems to avoid us hosting our own database that links tokens to a specific user, meaning that there will be no database for the user to compromise. Also, alexa itself already encrypts the entire payload so our token would essentially be double encrypted in transport.

The only downside I see to this is someone would be required to host the haaska lambda instance and incur and associated costs, but I suspect this would be either zero (for less than 1 million requests) or very small.

Clearly this would mean that the person hosting the haaska instance could potentially capture user data, but that is a risk for using any cloud service. So building user trust by not logging tokens and continually providing the entire codebase for review would be our biggest ally.

@trisk @auchter what do you think?

Trouble setting up haaska

I've followed the instructions here, and the YouTube video.

After checking, tweaking etc. I've managed to get the skill to show up in the Amazon Alexa app/website and successfully enable it, but it doesn't find anything after I've clicked on 'Discover Devices'.

Everything seems fine at developer.amazon.com and login.amazon.com, but at aws.amazon.com if I run a test (the one provided here) it shows the following log:

{
  "stackTrace": [
    [
      "/var/task/haaska.py",
      647,
      "event_handler",
      "config = Configuration('config.json')"
    ],
    [
      "/var/task/haaska.py",
      612,
      "__init__",
      "self._json = json.load(f)"
    ],
    [
      "/usr/lib64/python2.7/json/__init__.py",
      291,
      "load",
      "**kw)"
    ],
    [
      "/usr/lib64/python2.7/json/__init__.py",
      339,
      "loads",
      "return _default_decoder.decode(s)"
    ],
    [
      "/usr/lib64/python2.7/json/decoder.py",
      364,
      "decode",
      "obj, end = self.raw_decode(s, idx=_w(s, 0).end())"
    ],
    [
      "/usr/lib64/python2.7/json/decoder.py",
      380,
      "raw_decode",
      "obj, end = self.scan_once(s, idx)"
    ]
  ],
  "errorType": "ValueError",
  "errorMessage": "Expecting property name: line 4 column 1 (char 87)"
}

Does this make sense to anyone as to what the problem could be?

Process to upgrade to a new version

Hi,
Looks like there are a lot of new features bearing in mind the last comments. I tryed to upgrade the version according to the item "Upgrading" but it does not work for me.
I am really happy with this project and I am new on this.
Can you please improve the procedure to upgrade to a new version?
Can you please provide more details?
For example, It is neccesary to upgrade in the HA server? or in the Amazon cloud? or both?
Thanks a lot

Add __init__.py

In case haaska is used as an external package or as part of another Lambda...

Alexa and Haaska Issue

i followed exactly what bruhautomation said but i get the error message when i run the test.

{
"errorMessage": "Unable to import module 'lambda_function'"
}

i did upload the haaska file from my pi
clicked save and test and then i get the errormessage.

please help

Feature Request?

Would it be possible to add support for multiple friendly_names?
I would imagine that each name for a device would need to show up as its own device in the Alexa api.

Currently I am creating switch templates to use multiple names such as office lamp, office light etc.

It might look something like this.

customize:
  light.office:
  haaska_name: "office lamp", "office light", "office"

Help Sending Information to Amazon for config

Currently on the setup step to email amazon for provisioning, but not sure what to report for the Oauth section while using Login with Amazon. Is the Auth info somewhere on login with amazon?

not discovering lock

I have a lock in homeassistant, but alexa is not discovering it. lights and media players are discovered though.

Appending "Group" to group names is inconsistent with emulated Hue bridge

I'm trying out haaska instead of the emulated Philips Hue bridge in Home Assistant, but haaska appends the word "Group" to names of groups while the emulated_hue component does not.

So to control e.g. manually created groups in HA like "Lights" or automatic groups like "all devices", I now have to say "Alexa, turn on Lights Group" or "Alexa, turn off all devices Group".

Since the Alexa app/web interface shows the type of each device, I don't think it's necessary to indicate the type in the name. Forcing this naming convention makes a lot of uses of groups inconvenient since it makes the voice commands less natural.

Struggling to Get This Installed

Not an issue so much with Haaska, but rather the instructions for installation. The steps for creating an AWSlamba function appear to have changed. There is no way to enable account linking or to enable an event source unless I'm something. :(

Input Slider and Equivalent as Custom Temperature Control

Been looking at the smart home skill api for temperature control and query and it seems that it is viable for setting and controlling query and setpoint control.

We can set the mode to custom and provide a friendly name for the custom mode for whatever it is we want to query.

Use cases could be querying any number of numeric sensors, changing values and querying input booleans, but I do not have any specific use cases.

@dale3h what are your thoughts on this?

JSON config error

I'm currently getting an error when running the "Alexa Smart Home - Discovery" test using the amazon lamda function. My function is shown in my skills on the App and i have it enabled.

The log out put shows:
START RequestId: 5658d350-48bd-11e7-968a-cf0f4d9ff058 Version: $LATEST
[ERROR] 2017-06-04T00:32:49.897Z 5658d350-48bd-11e7-968a-cf0f4d9ff058 DiscoverAppliancesRequest failed
Traceback (most recent call last):
File "/var/task/haaska.py", line 113, in handle_discover_appliances
r['payload'] = {'discoveredAppliances': discover_appliances(ha)}
File "/var/task/haaska.py", line 164, in discover_appliances
states = ha.get('states')
File "/var/task/haaska.py", line 55, in get
return r.json()
File "/var/task/requests/models.py", line 886, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib64/python2.7/json/init.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python2.7/json/decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decodedEND RequestId: 5658d350-48bd-11e7-968a-cf0f4d9ff058
REPORT RequestId: 5658d350-48bd-11e7-968a-cf0f4d9ff058 Duration: 580.27 ms Billed Duration: 600 ms Memory Size: 128 MB Max Memory Used: 32 MB

Would anyone know whats causing this? I am using it in Australia could this be a possibility why it's not working? The only thing I've edited in the config file is the HA url (which I've set to my public ip address and port 8123) and the HA password - i know this is valid as I can access it via mobile and when changed the output log shows it cannot connect to the url.

Any help would be greatly appreciated!

skill does not discover devices but lambda does / InsecureRequestWarning

Hi all,

I have two questions.

1st question:

Running HA with https I get this warning in lambda log:

... InsecureRequestWarning ....

Is that something that I can ignore?

2nd question:

I'm able to discover devices running the lambda test on AWS

{
"header": {
"payloadVersion": "1",
"namespace": "Control",
"name": "DiscoverAppliancesRequest"
},
"payload": {
"accessToken": "whatever"
}
}

a part of lambda output:

{
"header": {
"payloadVersion": "2",
"namespace": "Alexa.ConnectedHome.Discovery",
"name": "DiscoverAppliancesResponse",
"messageId": "65b50bde-b357-4404-a75f-6e3bf1f1ef71"
},
"payload": {
"discoveredAppliances": [
{
"modelName": "Unknown",
"actions": [
"turnOn",
"turnOff"
],
"friendlyDescription": "Home Assistant Switch",
"version": "Unknown",
"additionalApplianceDetails": {
"entity_id": "switch.eg_esszimmer_steckdose_links",
"supported_features": 0
},
"manufacturerName": "Unknown",
"friendlyName": "Steckdose links",
"applianceId": "8e74c8c39cd4632aa17a4bc67bb4de2efe68dccf",
"isReachable": true
},
{
"modelName": "Unknown",
"actions": [
"turnOn",
"turnOff"
],
"friendlyDescription": "Home Assistant Switch",
"version": "Unknown",
"additionalApplianceDetails": {
"entity_id": "switch.1e_kl_gaeste_decke",
"supported_features": 0
},

Output haaska test:

{
"header": {
"payloadVersion": "2",
"namespace": "Alexa.ConnectedHome.System",
"name": "HealthCheckResponse",
"messageId": "4f076a1c-88fc-49f3-8828-b368223eddc6"
},
"payload": {
"isHealthy": true
}
}
true

Skill is enabled in Alexa but Alexa does not discover these/any devices.

Can anyone give me a hint debugging this? I have this issue with both configs (HA on http or https)

Thanks
Sven

Error on skill enable

When I try to enable the skill on the Alexa app it directs me to an amazon error webpage :
Login With Amazon
-An error occurred when we tried to process your request.

I've run the test on the Lambda console. It comes back okay.
I've followed the instructions on the Alexa avs github issues ( https://github.com/amzn/alexa-avs-raspberry-pi/issues/5).

Any ideas? What info would you all need to help me fix this?

struggling with this for a bit now please

Hi,
I think i have setup the haaska skill properly, following all steps to the T. but when I run the haaska function in lambda, i get this following message. Any help would be brilliant. I am using my public IP for home assistant. Not sure where i'm erring !

{
"stackTrace": [
[
"/var/task/haaska.py",
41,
"event_handler",
"cfg = get_config()"
],
[
"/var/task/haaska.py",
34,
"get_config",
"cfg = json.load(f)"
],
[
"/usr/lib64/python2.7/json/init.py",
290,
"load",
"**kw)"
],
[
"/usr/lib64/python2.7/json/init.py",
338,
"loads",
"return _default_decoder.decode(s)"
],
[
"/usr/lib64/python2.7/json/decoder.py",
366,
"decode",
"obj, end = self.raw_decode(s, idx=_w(s, 0).end())"
],
[
"/usr/lib64/python2.7/json/decoder.py",
382,
"raw_decode",
"obj, end = self.scan_once(s, idx)"
]
],
"errorType": "ValueError",
"errorMessage": "Expecting , delimiter: line 4 column 5 (char 84)"
}

Support Garage Doors

First off, thanks for this, it has open up many options for my smart home devices. Would it be possible / sensible to add support for garage doors? I have a raspberry pi garage door controller and would love if I could use "Alexa, open garage door." Currently I'm using IFTTT and "Alexa, trigger open garage door" just doesn't seem natural.

Thanks

Alexa does nothing on my command

So I set up haaska, all my devices from Home Assistant were descovered by Alexa phone app.
But, when I give a command like 'Alexa, turn on device', nothing happens.
In History, it appears that Alexa undestood my command correctly.
Is there a way to debug in Labda that the code receiced Alexa's command ?
Is there a way to test Lambda code for turning on/of devices ?

Thanks !

Update: I don't know why but is started working !

Make test error

$ make test
{
  "errorMessage": "2017-05-19T05:18:35.950Z 9a24631b-3c52-11e7-a65b-5f65a273a1ef Task timed out after 3.00 seconds"
}
null
Makefile:38: recipe for target 'test' failed
make: *** [test] Error 1

At the moment I can see the skill in "Your Skills" list in Amazon Alexa app Skills menu. After I enable it, I can't discover my devices in Home Assistant.

add support for thermostats

The new skills API supports commands for thermostats. haaska should support controlling thermostats in Home Assistant via this API.

haaska - Problem with Lambda

Hi,

I finished Alexa skill, Lambda Function, Register application and added to my Amazon Echo skill. However, it cannot discover the components I have in my home assistant.

I tried to trace back:

  • make test in Raspberry Pi = OK
  • test in Lambda = issue

Detail below.

What should I do to make it work?

make test in Raspberry Pi result:
pi@raspberrypi:~/haaska $ make test
{
"header": {
"payloadVersion": "2",
"namespace": "Alexa.ConnectedHome.System",
"name": "HealthCheckResponse",
"messageId": "ebd8f280-778e-4bdb-9c8f-18cc863e84d5"
},
"payload": {
"isHealthy": true
}
}
true

test in Lambda (Input):
{
"header": {
"payloadVersion": "1",
"namespace": "Control",
"name": "DiscoverAppliancesRequest"
},
"payload": {
"accessToken": "whatever"
}
}

test in Lambda (Error):
{
"stackTrace": [
[
"/var/task/haaska.py",
660,
"event_handler",
"ha, payload)"
],
[
"/var/task/haaska.py",
289,
"invoke",
"obj = make_class(allowed)(namespace, name, ha, context)"
]
],
"errorType": "AttributeError",
"errorMessage": "type object 'allowed' has no attribute 'Control'"
}

haaska - config.json:
{
"url": "https://my_ip:443/api",
"password": "my_password",
"expose_by_default": false
}

No Devices Found

Hi,
I followed your instructions and setup the Lambda function and linked it with the Alexa skill. I am not able to discover devices through the Alexa app. When I run the test I found here:

{
  "header": {
    "payloadVersion": "1",
    "namespace": "Control",
    "name": "DiscoverAppliancesRequest"
  },
  "payload": {
    "accessToken": "whatever"
  }

}

I get the following error:

Traceback (most recent call last):
  File "/var/task/haaska.py", line 668, in event_handler
    ha, payload)
  File "/var/task/haaska.py", line 294, in invoke
    obj = make_class(allowed)(namespace, name, ha, context)
AttributeError: type object 'allowed' has no attribute 'Control'

Any suggestions? ( I checked one of the closed issues which had a similar problem, and their issue resolved once they changed the lambda server to n.virginia, my Lambda function is already on n.virginia)

Alexa.PowerController

Found something interesting while issuing a "turn off" command to a media_player device that was exposed via the Video Skill API.

type object 'Alexa' has no attribute 'PowerController': AttributeError
Traceback (most recent call last):
File "/var/task/haaska.py", line 788, in event_handler
ha, event)
File "/var/task/haaska.py", line 404, in invoke
obj = make_class(allowed)(namespace, name, ha, event)
AttributeError: type object 'Alexa' has no attribute 'PowerController'

Looks like there's a new interface coming: Alexa.PowerController, with TurnOn and TurnOff methods. Couldn't find any documentation about this, though...

Localization support

Is there any interest in making the project localizable? I had to adjust some things in the code to make it work properly on my German Echo, so we could also add some basic localization support and adding a locale property in the config (being "en" by default).

HASSIO... how to?

I am wondering if there is a way to use this if I am running HASSIO?
Thanks for your time! This looks really awesome!

No devices discovered

Hey,

followed the installation guide both with video from Bruh.

I setup a skill and linked the account correct, but no devices could be discovered.
When running a test:

  "header": {
    "payloadVersion": "1",
    "namespace": "Control",
    "name": "DiscoverAppliancesRequest"
  },
  "payload": {
    "accessToken": "whatever"
  }
}

I'm getting:

Traceback (most recent call last):
  File "/var/task/haaska.py", line 660, in event_handler
    ha, payload)
  File "/var/task/haaska.py", line 289, in invoke
    obj = make_class(allowed)(namespace, name, ha, context)
AttributeError: type object 'allowed' has no attribute 'Control'

What could be wrong?

Giving haaska/Alexa some 'personality'?

For the 'other' Home Assistant Alexa skill you can 'give Alexa some personality' by adding various different replies from Alexa once it's activated something for you (instead of just saying OK).

Is it possible to do that with this skill? I don't know much about this, but it would be nice to have different replies instead of just 'OK' all the time.

Alexa commands

Can I say 'Alexa open [Script Name] to start a script on home assistant?

Saw the list of turn on and off commands on the readme, but only 'Alexa, turn on...' and 'Alexa, turn off...' seem to be working for me.

Thanks

ValueOutOfRangeError when setting thermostat temperature

Not sure why, but all the sudden I am getting messages from alexa that the temperature I requested to set the thermostat to is not within the allowed range. The following code is the culprit.

if new > max_temp or new < min_temp:
    raise ValueOutOfRangeError(min_temp, max_temp)

However, casting new, max_temp and min_temp to floats like this seemed to fix it:

if float(new) > float(max_temp) or float(new) < float(min_temp):
    raise ValueOutOfRangeError(min_temp, max_temp)

I also had to update this code as well:

e.set_temperature(float(new), mode.lower(), state)

I'd be happy to submit a pull request for the changes, but I wanted to get some thoughts on how best to solve this first. @trisk can you chime in?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.