Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Garden Aid - IoT - Moisture Check
const AWS = require('aws-sdk');
const sns = new AWS.SNS();
// Example event
// { DeviceId: 'test-js-device', Recorded: '2016-08-14T12:39:06.765Z', Level: 3.59334681998007 }
module.exports.checkLevel = (event, context, cb) => {
if(event.Level >= 2.5) {
cb(null, { message: 'No message to publish', event: event });
return;
}
const params = {
Message: JSON.stringify({
message: 'Moisture level has dropped to ' + event.Level
}),
TopicArn: process.env.mositureNotifyTopic
};
sns.publish(params, cb);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.