First pass at adding applianceTypes

This commit is contained in:
Ben Hardill
2018-02-10 08:56:49 +00:00
parent 35ed356999
commit 82e495922b
5 changed files with 24 additions and 13 deletions

View File

@@ -156,7 +156,7 @@ Account.findOne({username: mqtt_user}, function(error, account){
}
});
var app_id = 'https://localhost:' + port;
var app_id = 'http://localhost:' + port;
if (process.env.VCAP_APPLICATION) {
var application = JSON.parse(process.env.VCAP_APPLICATION);
@@ -183,7 +183,7 @@ app.use(session({
resave: false,
saveUninitialized: false,
cookie: {
secure: true
//secure: true
}
}));
app.use(bodyParser.json());
@@ -264,19 +264,27 @@ app.get('/logout', function(req,res){
//app.post('/login',passport.authenticate('local', { failureRedirect: '/login', successRedirect: '/2faCheck', failureFlash: true }));
app.post('/login',
passport.authenticate('local', { failureRedirect: '/login', failureFlash: true, session: true }),
passport.authenticate('local',{ failureRedirect: '/login', failureFlash: true, session: true }),
function(req,res){
console.log("login success");
console.log(req.isAuthenticated());
console.log(req.user);
if (req.query.next) {
res.reconnect(req.query.next);
} else {
console.log("passed Auth");
res.redirect('/devices');
}
});
function ensureAuthenticated(req,res,next) {
console.log("ensureAuthenticated - %j", req.isAuthenticated());
console.log("ensureAuthenticated - %j", req.user);
console.log("ensureAuthenticated - %j", req.session);
if (req.isAuthenticated()) {
return next();
} else {
console.log("failed auth?");
res.redirect('/login');
}
}
@@ -519,6 +527,7 @@ app.get('/api/v1/devices',
dev.applianceId = "" + data[i].applianceId;
dev.isReachable = data[i].isReachable;
dev.actions = data[i].actions;
dev.applianceTypes = data[i].applianceTypes;
dev.additionalApplianceDetails = data[i].additionalApplianceDetails;
dev.modelName = "Node-RED Endpoint";
dev.version = "0.0.1";
@@ -673,6 +682,7 @@ app.post('/device/:dev_id',
} else {
data.friendlyDescription = device.friendlyDescription;
data.actions = device.actions;
data.applianceTypes = device.applianceTypes;
data.save(function(err, d){
res.status(201);
res.send(d);
@@ -893,4 +903,4 @@ server.listen(port, host, function(){
});
});

View File

@@ -9,6 +9,7 @@ var Devices = new Schema({
friendlyDescription: String,
isReachable: Boolean,
actions: [String],
applianceTypes: [String],
additionalApplianceDetails: {
extraDetail1: String,
extraDetail2: String,

1
static/images/paypal.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" aria-label="PayPal" role="img" viewBox="0 0 512 512"><rect width="512" height="512" fill="#003087" rx="15%"/><g fill="#fff"><path d="M431 126c17 30 11 65 4 85-35 114-195 107-218 107-24 0-29 21-29 21l-17 74c-5 26-29 25-29 25H90l-4-1c0 5 1 19 18 19h52s24 1 29-25l17-73s6-21 29-21 183 6 219-107c8-25 14-72-19-104z"/><path d="M155 397l17-74s5-21 29-21c23 0 183 6 218-107 13-41 22-139-139-139H163s-24-1-30 24L56 401s-3 21 18 21h52s24 1 29-25zm44-187l15-65s5-18 21-21c16-2 43 1 50 2 46 8 36 50 36 50-9 65-112 56-112 56-16-6-10-22-10-22z"/></g></svg>

After

Width:  |  Height:  |  Size: 584 B

View File

@@ -9,7 +9,7 @@
<p>If you have a bug with the service please raise an issue on github <a href="https://github.com/hardillb/node-red-alexa-home-skill-web/issues">here</a></p>
<h2>Thanks</h2>
<p>If on the other hand you just want to say thanks, you can always throw a few quid my way to buy me a beer via <a href="https://paypal.me/hardillb/5">paypal</a></p>
<p>If on the other hand you just want to say thanks, you can always throw a few quid my way to buy me a beer via <a href="https://paypal.me/hardillb/5"><img src="/images/paypal.svg" style="width: 20px; height: 20px;" alt="paypal"> paypal</a></p>
<h2>Privacy Policy</h2>
<p>No information held by this sevice will be shared with 3rd parties, with the exception of the oAuth
@@ -18,4 +18,4 @@
</div
<% include ../fragments/footer.ejs %>
<% include ../fragments/footer.ejs %>

View File

@@ -352,18 +352,17 @@ npm install node-red-contrib-alexa-home-skill</pre>
}
msg.payload = false;
msg.extra = range;
return [[],msg];
} else {
var success = RED.util.cloneMessage(msg);
success.payload = true;
success.extra = {
msg.payload = true;
msg.extra = {
targetTemperature: {
value: msg.payload
}
}
return [[msg],success];
}</pre>
}
return msg;</pre>
<p>This enforces a temperature range between 10&deg;C and 30&deg;C, sending the Alexa response to the second output and
if the input is in range the control message is sent to the first function output. Note: All values are passed in Degrees
C even if the input voice commands are in Degrees F when using Alexa in the US.</p>