Skip to content

Commit d5fa604

Browse files
Initial Commit
0 parents  commit d5fa604

34 files changed

Lines changed: 1150 additions & 0 deletions

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*Issue #, if available:*
2+
3+
*Description of changes:*
4+
5+
6+
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

.gitignore

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
.idea/
2+
3+
#gitref https://gist.github.com/octocat/9257657#file-gitignore
4+
# Compiled source #
5+
###################
6+
*.com
7+
*.class
8+
*.dll
9+
*.exe
10+
*.o
11+
*.so
12+
13+
# Packages #
14+
############
15+
# it's better to unpack these files and commit the raw source
16+
# git has its own built in compression methods
17+
*.7z
18+
*.dmg
19+
*.gz
20+
*.iso
21+
*.jar
22+
*.rar
23+
*.tar
24+
*.zip
25+
26+
# Logs and databases #
27+
######################
28+
*.log
29+
*.sql
30+
*.sqlite
31+
32+
# OS generated files #
33+
######################
34+
.DS_Store
35+
.DS_Store?
36+
._*
37+
.Spotlight-V100
38+
.Trashes
39+
ehthumbs.db
40+
Thumbs.db
41+
42+
### Python template
43+
# Byte-compiled / optimized / DLL files
44+
__pycache__/
45+
*.py[cod]
46+
*$py.class
47+
48+
# C extensions
49+
*.so
50+
51+
# Distribution / packaging
52+
.Python
53+
build/
54+
develop-eggs/
55+
dist/
56+
downloads/
57+
eggs/
58+
.eggs/
59+
lib/
60+
lib64/
61+
parts/
62+
sdist/
63+
var/
64+
wheels/
65+
*.egg-info/
66+
.installed.cfg
67+
*.egg
68+
MANIFEST
69+
70+
# PyInstaller
71+
# Usually these files are written by a python script from a template
72+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
73+
*.manifest
74+
*.spec
75+
76+
# Installer logs
77+
pip-log.txt
78+
pip-delete-this-directory.txt
79+
80+
# Unit test / coverage reports
81+
htmlcov/
82+
.tox/
83+
.coverage
84+
.coverage.*
85+
.cache
86+
nosetests.xml
87+
coverage.xml
88+
*.cover
89+
.hypothesis/
90+
.pytest_cache/
91+
92+
# Translations
93+
*.mo
94+
*.pot
95+
96+
# Django stuff:
97+
*.log
98+
local_settings.py
99+
db.sqlite3
100+
101+
# Flask stuff:
102+
instance/
103+
.webassets-cache
104+
105+
# Scrapy stuff:
106+
.scrapy
107+
108+
# Sphinx documentation
109+
docs/_build/
110+
111+
# PyBuilder
112+
target/
113+
114+
# Jupyter Notebook
115+
.ipynb_checkpoints
116+
117+
# pyenv
118+
.python-version
119+
120+
# celery beat schedule file
121+
celerybeat-schedule
122+
123+
# SageMath parsed files
124+
*.sage.py
125+
126+
# Environments
127+
.env
128+
.venv
129+
env/
130+
venv/
131+
ENV/
132+
env.bak/
133+
venv.bak/
134+
135+
# Spyder project settings
136+
.spyderproject
137+
.spyproject
138+
139+
# Rope project settings
140+
.ropeproject
141+
142+
# mkdocs documentation
143+
/site
144+
145+
# mypy
146+
.mypy_cache/

CODE_OF_CONDUCT.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Code of Conduct
2+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4+
opensource-codeofconduct@amazon.com with any additional questions or comments.

CONTRIBUTING.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Contributing Guidelines
2+
3+
Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4+
documentation, we greatly value feedback and contributions from our community.
5+
6+
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7+
information to effectively respond to your bug report or contribution.
8+
9+
10+
## Reporting Bugs/Feature Requests
11+
12+
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13+
14+
When filing an issue, please check [existing open](https://github.com/alexa/skill-sample-python-smarthome-switch/issues), or [recently closed](https://github.com/alexa/skill-sample-python-smarthome-switch/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already
15+
reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16+
17+
* A reproducible test case or series of steps
18+
* The version of our code being used
19+
* Any modifications you've made relevant to the bug
20+
* Anything unusual about your environment or deployment
21+
22+
23+
## Contributing via Pull Requests
24+
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
25+
26+
1. You are working against the latest source on the *master* branch.
27+
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
28+
3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
29+
30+
To send us a pull request, please:
31+
32+
1. Fork the repository.
33+
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34+
3. Ensure local tests pass.
35+
4. Commit to your fork using clear commit messages.
36+
5. Send us a pull request, answering any default questions in the pull request interface.
37+
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
38+
39+
GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
40+
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
41+
42+
43+
## Finding contributions to work on
44+
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/alexa/skill-sample-python-smarthome-switch/labels/help%20wanted) issues is a great place to start.
45+
46+
47+
## Code of Conduct
48+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
50+
opensource-codeofconduct@amazon.com with any additional questions or comments.
51+
52+
53+
## Security issue notifications
54+
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
55+
56+
57+
## Licensing
58+
59+
See the [LICENSE](https://github.com/alexa/skill-sample-python-smarthome-switch/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
60+
61+
We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.

LICENSE

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
Amazon Software License 1.0
2+
3+
This Amazon Software License ("License") governs your use, reproduction, and
4+
distribution of the accompanying software as specified below.
5+
6+
1. Definitions
7+
8+
"Licensor" means any person or entity that distributes its Work.
9+
10+
"Software" means the original work of authorship made available under this
11+
License.
12+
13+
"Work" means the Software and any additions to or derivative works of the
14+
Software that are made available under this License.
15+
16+
The terms "reproduce," "reproduction," "derivative works," and
17+
"distribution" have the meaning as provided under U.S. copyright law;
18+
provided, however, that for the purposes of this License, derivative works
19+
shall not include works that remain separable from, or merely link (or bind
20+
by name) to the interfaces of, the Work.
21+
22+
Works, including the Software, are "made available" under this License by
23+
including in or with the Work either (a) a copyright notice referencing the
24+
applicability of this License to the Work, or (b) a copy of this License.
25+
26+
2. License Grants
27+
28+
2.1 Copyright Grant. Subject to the terms and conditions of this License,
29+
each Licensor grants to you a perpetual, worldwide, non-exclusive,
30+
royalty-free, copyright license to reproduce, prepare derivative works of,
31+
publicly display, publicly perform, sublicense and distribute its Work and
32+
any resulting derivative works in any form.
33+
34+
2.2 Patent Grant. Subject to the terms and conditions of this License, each
35+
Licensor grants to you a perpetual, worldwide, non-exclusive, royalty-free
36+
patent license to make, have made, use, sell, offer for sale, import, and
37+
otherwise transfer its Work, in whole or in part. The foregoing license
38+
applies only to the patent claims licensable by Licensor that would be
39+
infringed by Licensor's Work (or portion thereof) individually and
40+
excluding any combinations with any other materials or technology.
41+
42+
3. Limitations
43+
44+
3.1 Redistribution. You may reproduce or distribute the Work only if
45+
(a) you do so under this License, (b) you include a complete copy of this
46+
License with your distribution, and (c) you retain without modification
47+
any copyright, patent, trademark, or attribution notices that are present
48+
in the Work.
49+
50+
3.2 Derivative Works. You may specify that additional or different terms
51+
apply to the use, reproduction, and distribution of your derivative works
52+
of the Work ("Your Terms") only if (a) Your Terms provide that the use
53+
limitation in Section 3.3 applies to your derivative works, and (b) you
54+
identify the specific derivative works that are subject to Your Terms.
55+
Notwithstanding Your Terms, this License (including the redistribution
56+
requirements in Section 3.1) will continue to apply to the Work itself.
57+
58+
3.3 Use Limitation. The Work and any derivative works thereof only may be
59+
used or intended for use with the web services, computing platforms or
60+
applications provided by Amazon.com, Inc. or its affiliates, including
61+
Amazon Web Services, Inc.
62+
63+
3.4 Patent Claims. If you bring or threaten to bring a patent claim against
64+
any Licensor (including any claim, cross-claim or counterclaim in a
65+
lawsuit) to enforce any patents that you allege are infringed by any Work,
66+
then your rights under this License from such Licensor (including the
67+
grants in Sections 2.1 and 2.2) will terminate immediately.
68+
69+
3.5 Trademarks. This License does not grant any rights to use any
70+
Licensor's or its affiliates' names, logos, or trademarks, except as
71+
necessary to reproduce the notices described in this License.
72+
73+
3.6 Termination. If you violate any term of this License, then your rights
74+
under this License (including the grants in Sections 2.1 and 2.2) will
75+
terminate immediately.
76+
77+
4. Disclaimer of Warranty.
78+
79+
THE WORK IS PROVIDED "AS IS" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
80+
EITHER EXPRESS OR IMPLIED, INCLUDING WARRANTIES OR CONDITIONS OF
81+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR
82+
NON-INFRINGEMENT. YOU BEAR THE RISK OF UNDERTAKING ANY ACTIVITIES UNDER
83+
THIS LICENSE. SOME STATES' CONSUMER LAWS DO NOT ALLOW EXCLUSION OF AN
84+
IMPLIED WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO YOU.
85+
86+
5. Limitation of Liability.
87+
88+
EXCEPT AS PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL
89+
THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE
90+
SHALL ANY LICENSOR BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT,
91+
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR
92+
RELATED TO THIS LICENSE, THE USE OR INABILITY TO USE THE WORK (INCLUDING
93+
BUT NOT LIMITED TO LOSS OF GOODWILL, BUSINESS INTERRUPTION, LOST PROFITS
94+
OR DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY OTHER COMM ERCIAL DAMAGES
95+
OR LOSSES), EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF
96+
SUCH DAMAGES.

NOTICE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Skill Sample Python Smarthome Switch
2+
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Skill Sample : Smarthome Switch (Python)
2+
3+
This is a basic Alexa Smart Home skill sample that implements a virtual switch. It shows the discovery and directive handling process for a virtual device implementing Alexa Smart Home switch capabilities.
4+
5+
## Instructions
6+
To use this sample, follow the [Instructions](instructions/README.md).
7+
8+
## License
9+
10+
This library is licensed under the Amazon Software License.

instructions/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Instructions
2+
3+
4+
## skill-sample-python-smarthome-switch
5+
These instructions are to build a Sample Alexa Smart Home skill using Python that creates and controls a virtual sample switch that responds to ON/OFF commands.
6+
7+
## Setup the Alexa Smart Home Sample via the Alexa Developer Console
8+
9+
1. [Setup the Sample Resources](setup-the-sample-resources.md)
10+
2. [Get the Sample Source Code](get-the-sample-source-code.md)
11+
3. [Setup Login with Amazon](setup-login-with-amazon.md)
12+
4. [Create the Skill](create-the-skill.md)
13+
5. [Setup the Lambda Function](setup-the-lambda-function.md)
14+
6. [Configure the Skill](configure-the-skill.md)
15+
7. [Deploy the Sample Code](deploy-the-sample-code.md)
16+
8. [Test the Skill](test-the-skill.md)
17+
9. [Review the Skill Logs](review-the-skill-logs.md)
18+
19+
To begin, start with [Setup the Sample Resources](setup-the-sample-resources.md)
20+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Configure the Skill
2+
3+
Configure the Alexa Smart Home skill and fill out the required settings.
4+
5+
## Configure the Smart Home settings
6+
7+
1. Return to the Alexa Skills Kit Developer Console at https://developer.amazon.com/alexa/console/ask and open your skill-sample-python-smarthome-switch skill.
8+
2. On the *SMART HOME* tab, leave the Payload version at v3.
9+
3. For the *Smart Home service endpoint*, enter the ARN saved in your `setup.txt` file as [AWS Lambda ARN] into the *Default endpoint* field. The ARN should look something like: `arn:aws:lambda:us-east-1:XXXXXXXXXXXX:function:skill-sample-language-smarthome-switch`
10+
4. Click **Save**. If you get an error stating “Failed to save skill information, Please make sure that "Alexa Smart Home" is selected for the event source type...” return to your AWS Lambda for the *skill-sample-python-smarthome-switch* function and verify you correctly set and saved the Smart Home trigger.
11+
12+
## Configure the Account Linking settings
13+
14+
1. Either select the *ACCOUNT LINKING *tab on the left or the **Setup Account Linking** button at the bottom of the page.
15+
2. On the *Account Linking* page, for the *Authorization URI*, enter `https://www.amazon.com/ap/oa`.
16+
3. For the Access Token URI, enter `https://api.amazon.com/auth/o2/token`.
17+
4. For the Client ID, copy and paste the previously saved [Login with Amazon Client ID] value from the `setup.txt` file.
18+
5. For the Client Secret, copy and paste the previously saved [Login with Amazon Client Secret] value from the `setup.txt` file.
19+
6. Under *Scope*, click the **+ Add scope** link and then add the following scope into the text box: `profile:user_id`
20+
7. Copy the three (3) redirect urls from the Redirect URLs section and save them to the [Redirect URLs] section of the `setup.txt` file.
21+
8. Click **Save**.
22+
23+
## Set the Allowed Return URLs
24+
25+
Using your account-specific values from the skill configuration section, collect the Redirect URLs and set them in the *Security Profile Web Settings* **Allowed Return URLs**.
26+
27+
1. Open https://developer.amazon.com/iba-sp/overview.html in another browser tab and make sure *APPS & SERVICES* is selected in the top menu and *Security Profiles* is selected in the sub menu.
28+
2. Select the **Smart Home Sample** Security Profile.
29+
3. On the *Security Profile Management* page, select the **Web Settings** tab.
30+
4. In the *Web Settings*, click the **Edit** button.
31+
5. In the Allowed Return URLs text input, add each of the saved Redirect URLs from the `setup.txt` file. You will need to click the **Add Another** link to add each Return/Redirect URL. Each of the Return/Redirect URLs will have a format similar to `https://pitangui.amazon.com/api/skill/link/XXXXXXXXXXXXXX`
32+
6. Click **Save**.
33+
34+
35+
Next [Deploy the Sample Code](deploy-the-sample-code.md)
36+
37+
Return to the [Instructions](README.md)

0 commit comments

Comments
 (0)