Skip to content

Instantly share code, notes, and snippets.

View jmaukisch's full-sized avatar

Jens Maukisch jmaukisch

  • comSysto
View GitHub Profile
{
"things": [
{
"thingName": "esp32_AAAAAA",
"thingArn": "arn:aws:iot:eu-west-1:XXXXXX:thing/esp32_AAAAAA",
"attributes": {},
"version": 1
}
]
}
{
"state": {
"reported": {
"humidity": 81,
"temp": 21.1
}
},
"metadata": {
"reported": {
"humidity": {
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iot:GetThingShadow",
"Resource": [
"arn:aws:iot:eu-west-1:XXXXXX:thing/esp32_AAAAAA",
"arn:aws:iot:eu-west-1:XXXXXX:thing/esp32_BBBBBB",
"arn:aws:iot:eu-west-1:XXXXXX:thing/esp32_CCCCCC"
async function getSensorData(sensorName) {
const credentials = await getCredentials();
const iotData = new AWS.IotData({
endpoint: config.IOT_BROKER_ENDPOINT,
accessKeyId: credentials.Credentials.AccessKeyId,
secretAccessKey: credentials.Credentials.SecretAccessKey,
sessionToken: credentials.Credentials.SessionToken
});
const data = await iotData.getThingShadow({ thingName: sensorName }).promise();
return JSON.parse(data.payload);
async handle(handlerInput) {
const room = getSlotValue(handlerInput.requestEnvelope, 'room');
const roomSensor = config.ROOMS[room];
const sensorData = await getSensorData(roomSensor);
const measurement = getSlotValue(handlerInput.requestEnvelope, 'measurement');
var speech = new Speech();
if (measurement === 'temperatur') {
speech.say('Es ist im')
speech.say(room)
canHandle(handlerInput) {
return getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& getIntentName(handlerInput.requestEnvelope) === 'GetMeasurementForRoom';
}
{
"requestEnvelope": {
"version": "1.0",
"request": {
"type": "IntentRequest",
"requestId": "1234",
"locale": "de-DE",
"timestamp": "2020-08-25T12:51:52Z",
"intent": {
"name": "GetMeasurementForRoom",
load('api_timer.js');
load('api_aws.js'); // aws support
load('api_dht.js'); // helper for the dht22 sensor
let dht = DHT.create(32, DHT.DHT22);
// get a new value every 5mins
Timer.set(300000, true, function() {
let currentTemp = dht.getTemp();
let currentHumidity = dht.getHumidity();
manifest_version: 2017-09-29
libs_version: ${mos.version}
modules_version: ${mos.version}
mongoose_os_version: ${mos.version}
# List of files/folders copied to the device filesystem
filesystem:
- fs