Python application that runs on Heroku, collects data pertaining to various cities and reports the data to AT&T M2X.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
citystats
data
.gitignore
LICENSE initial commit Jun 4, 2015
Procfile
README.md
__init__.py
app.json
clock.py
requirements.txt initial commit Jun 4, 2015

README.md

Citystats

citystats-logo

Introduction

This application runs on Heroku, collects data pertaining to various cities and reports the data to AT&T's M2X time-series data service.

Check out the data which I've made publicly available via my account on M2X @ M2X Public Device Catalog

Pre-Requisites

You will need to have an account on the following services:

  1. M2X: M2X is an IoT time-series data storage service. The M2X developer tier account is free for up to 10 devices @ 100,000 max data points written per device/month. This application creates one M2X device per city listed in /data/cities.txt, as long as there are 10 or fewer cities listed in that file you will be able to utilize this application with a developer tier account. The current build of the application pushes less than 10,000 datapoints per device, well under the developer tier limit. Should you desire more capacity you'll need to upgrade your M2X Account.
  2. Heroku: Heroku is a PaaS that enables developers to build and run applications entirely in the cloud. Because this example application uses only one Heroku dyno, it should be free for you to use, no matter how many other Heroku applications you have.
  3. Forecast.io: Forecast.io is a global weather service with an open API for accessing weather data. The Forecast.io developer account is free and allows for up to 1000 API calls per month. This application utilizes Forecast.io to retrieve weather data for the cities listed in /data/cities.txt.

API Keys

Obtain your Forecast.io API Key from their developer portal

Installation

Deploying your application

Click the Heroku button to deploy your application to Heroku:

Deploy

Setup Config Variables in Heroku

Via Heroku CLI

(requires Heroku Toolbelt)

Forecast.io API Key:

heroku config:set FORECAST_API_KEY={YOUR-FORECAST.IO-API-KEY}

Via Heroku Dashboard

You can also edit config vars on your app’s settings tab on your Heroku Dashboard.

Adjust /data/cities.txt (optional)

Adjust the list of cities in /data/cities.txt if desired. This is a newline separated list of Cities that will be tracked by this app. Forecast data from Forecast.io is retrieved for the cities listed in /data/cities.txt.

Scaling Your Application

Scale the number of clock workers to 1, once this is done the clock.py script will start and is set up to run every 2 days. Why 2 days? Hourly forecast data from Forecast.io returns data for the past 48 hours, so the script is set up to run every 2 days.

Via Heroku CLI

heroku ps:scale clock=1

Via Heroku Dashboard

Go to the Resources tab on your application's dashboard on Heroku and scale the python clock.py process so that it uses one dyno.

Issues

Feel free to report any issues you encounter with this app via GitHub

Thanks to...

LICENSE

This sample application is released under the MIT license. See LICENSE for the terms.