Created
March 17, 2022 09:36
-
-
Save johnlpage/a0c6116e3a6dc57af0e66f8106e25014 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports = async function() { | |
let APIKEY = context.values.get('ifftkey_value') | |
const collection = context.services.get("mongodb-atlas").db("energy").collection("meter"); | |
const docs = await collection.find({ type: "electric" }).sort({_id:-1}).limit(1).toArray(); | |
if(docs.length == 1) | |
{ | |
if(docs[0].solarwatts > 800) { | |
console.log("turning off lights") | |
const response = context.http.get({ url: `https://maker.ifttt.com/trigger/AllLightsOff/with/key/${APIKEY}` }) | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment