Giter Club home page Giter Club logo

aws-lambda-air-visual-pro-twilio-alerts's Introduction

twilio-lambda-cron

This project will poll an AirVisual Pro device-specific API endpoint using a cron trigger and alert if the CO2 concentration or PM2.5 is above a configurable threshold. This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. You must have an AirVisual Pro device linked to an iqair.com account to make use of this respository.

Deploy the sample application

The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API.

To use the SAM CLI, you need the following tools.

You will also need a Twilio account with Account SID and Auth Token.

To build and deploy your application for the first time, run the following in your shell:

sam build
sam deploy --guided

Environment variables

The following environment variables should be configured:

  • TWILIO_ACCOUNT_SID: Your Twilio Account SID from the Twilio Console
  • TWILIO_AUTH_TOKEN: Your Twilio Auth Token from the Twilio Console
  • TWILIO_PHONE_NUMBER: Your Twilio Phone number in E164 format
  • DESTINATION_ALERT_PHONE_NUMBER: Your destination alert phone number in E164 format
  • AIR_QUALITY_API: The HTTPS URL to your AirVisual Node API obtained from your AirVisual devices dashboard in format https://www.airvisual.com/api/v2/node/{uniqueDeviceApiLink}
  • PM2_LIMIT: PM2.5 limit in µg/m^3
  • CO2_LIMIT: CO2 threshold in PPM (parts per million)

Cron configuration

In your template.yaml, configure the cron expression desired for alerting. The alert text message will only be sent during the cron schedule if one of the measured values exceeds the threshold defined in the two limits. An example cron expression which checks every 15 minutes between 1300-2300 UTC during weekdays (MON-FRI) is provided.

aws-lambda-air-visual-pro-twilio-alerts's People

Contributors

randyjohnston avatar snyk-bot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.