Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump stringstream from 0.0.5 to 0.0.6 #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
error.log
error.log
wip
6 changes: 6 additions & 0 deletions alexa/thermostat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# package directories
node_modules
jspm_packages

# Serverless directories
.serverless
13 changes: 13 additions & 0 deletions alexa/thermostat/handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const Alexa = require('alexa-sdk');

const handlers = {
"heater": require('./handlers/heaterControlHandler'),
"Unhandled": require('./handlers/heaterControlHandler')
}

module.exports.alfred = (event, context, callback) => {
let alexa = Alexa.handler(event, context);
alexa.appId = process.env.ALEXA_THERMOSTAT;
alexa.registerHandlers(handlers);
alexa.execute();
};
20 changes: 20 additions & 0 deletions alexa/thermostat/handlers/heaterControlHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const request = require('request');

module.exports = function() {
let emit = this.emit
let action = this.event.request.intent.slots && this.event.request.intent.slots.status.value || 'off';
request(`http://${process.env.HOME_IP}:30387/thermostat?action=${action}`, (error, response, body) => {
if (error) {
console.log(error);
emit(':tell', "There is a problem connecting to Raspberry Pi!");
}
else {
console.log('All good');
if (action == 'on') {
emit(':tell', "The heater is on, but you don't need it. You're hot!");
} else {
emit(':tell', "The heater is off. I told you, you're hot enough!");
}
}
});
}
17 changes: 17 additions & 0 deletions alexa/thermostat/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "thermostat",
"version": "1.0.0",
"description": "",
"main": "handler.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"alexa-sdk": "^1.0.21",
"aws-sdk": "^2.156.0",
"gabokapu-alexa-sdk": "^1.0.7",
"request": "^2.83.0"
}
}
109 changes: 109 additions & 0 deletions alexa/thermostat/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
# docs.serverless.com
#
# Happy Coding!

service: alfred # NOTE: update this with your service name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"

provider:
name: aws
runtime: nodejs8.10

# you can overwrite defaults here
# stage: dev
# region: us-east-1
region: eu-west-1

# you can add statements to the Lambda function's IAM Role here
# iamRoleStatements:
# - Effect: "Allow"
# Action:
# - "s3:ListBucket"
# Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] }
# - Effect: "Allow"
# Action:
# - "s3:PutObject"
# Resource:
# Fn::Join:
# - ""
# - - "arn:aws:s3:::"
# - "Ref" : "ServerlessDeploymentBucket"
# - "/*"

# you can define service wide environment variables here
# environment:
# variable1: value1
environment:
ALEXA_THERMOSTAT: amzn1.ask.skill.669e3ec3-7f75-4914-b16f-62c4c029d683
HOME_IP: 46.238.10.186
# you can add packaging information here
#package:
# include:
# - include-me.js
# - include-me-dir/**
# exclude:
# - exclude-me.js
# - exclude-me-dir/**

functions:
alfred:
handler: handler.alfred

events:
- alexaSkill
# The following are a few example events you can configure
# NOTE: Please make sure to change your handler code to work with those events
# Check the event documentation for details
# events:
# - http:
# path: users/create
# method: get
# - s3: ${env:BUCKET}
# - schedule: rate(10 minutes)
# - sns: greeter-topic
# - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000
# - alexaSkill: amzn1.ask.skill.xx-xx-xx-xx
# - alexaSmartHome: amzn1.ask.skill.xx-xx-xx-xx
# - iot:
# sql: "SELECT * FROM 'some_topic'"
# - cloudwatchEvent:
# event:
# source:
# - "aws.ec2"
# detail-type:
# - "EC2 Instance State-change Notification"
# detail:
# state:
# - pending
# - cloudwatchLog: '/aws/lambda/hello'
# - cognitoUserPool:
# pool: MyUserPool
# trigger: PreSignUp

# Define function environment variables here
# environment:
# variable2: value2

# you can add CloudFormation resource templates here
#resources:
# Resources:
# NewResource:
# Type: AWS::S3::Bucket
# Properties:
# BucketName: my-new-bucket
# Outputs:
# NewOutput:
# Description: "Description for the output"
# Value: "Some output value"
2 changes: 1 addition & 1 deletion alexa/tvControl/handlers/tvChannelControlHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function() {
dynamoDb.query(params,(err, result) => {
if (err || result.Count == 0) emit(':tell', "Channel was not found in dynamo db database");
else {
request(`http://${process.env.HOME_IP}:3000/tv?command=${result.Items[0].number}`, (error, response, body) => {
request(`http://${process.env.HOME_IP}:30387/tv?command=${result.Items[0].number}`, (error, response, body) => {
if (!error) emit(':tell', "ok");
});
}
Expand Down
2 changes: 1 addition & 1 deletion alexa/tvControl/handlers/tvStatusControlHandler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const request = require('request');

module.exports = function() {
request(`http://${process.env.HOME_IP}:3000/tv?command=KEY_POWER`, (error, response, body) => {
request(`http://${process.env.HOME_IP}:3000/tv?command=power`, (error, response, body) => {
if (error) this.emit(':tell', "There is a problem connecting to Raspberry Pi!");
else this.emit(':tell', "OK");
});
Expand Down
2 changes: 1 addition & 1 deletion alexa/tvControl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"aws-sdk": "^2.156.0",
"request": "^2.83.0"
}
}
}
Loading