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
// Import Electric Imp's REST API management library | |
#require "Rocky.class.nut:2.0.0" | |
// Replace the following two strings with your server logging endpoint | |
const RESULTS_URL = "<YOUR_RESULT_LOGGING_URL>"; | |
// Define the web page HTML as a constant | |
const HTML_STRING = @"<!DOCTYPE html><html lang='en-US'><meta charset='UTF-8'> | |
<html> | |
<head> |
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
// CONSTANTS | |
// Replace the 'USERNAME' and 'PASSWORD' values with your own, and enter | |
// Replace the 'DEVICE_ID' value with the ID of a device accessible via impCentral (not the IDE) | |
// Replace the 'ACCESS_TOKEN' value with one retrieved using 'products.js' at | |
// https://gist.github.com/ElectricImpSampleCode/f0fb7f8bd04be009beeb5ee86dbd406a | |
const USERNAME = '...'; | |
const PASSWORD = '...'; | |
const DEVICE_ID = '...'; | |
const ACCESS_TOKEN = '...'; | |
const API_URL = 'api.electricimp.com'; |
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
// CONSTANTS | |
// Replace the 'USERNAME' and 'PASSWORD' values with your own | |
const USERNAME = '...' | |
const PASSWORD = '...' | |
const API_URL = 'api.electricimp.com' | |
const API_VER = '/v5/' | |
const FILE_NAME = '.impCentralData' | |
// GLOBALS | |
var https = require('https'); |
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
// CONSTANTS | |
// Replace the 'USERNAME' and 'PASSWORD' values with your own | |
// Replace the 'ACCESS_TOKEN' value with one retrieved using 'products.js' at | |
// https://gist.github.com/ElectricImpSampleCode/f0fb7f8bd04be009beeb5ee86dbd406a | |
const USERNAME = '...' | |
const PASSWORD = '...' | |
const ACCESS_TOKEN = '...' | |
const API_URL = 'api.electricimp.com' | |
const API_VER = '/v5/' |
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
// CONSTANTS | |
// Replace the 'USERNAME' and 'PASSWORD' values with your own | |
// Replace the 'ACCESS_TOKEN' value with one retrieved using 'products.js' at | |
// https://gist.github.com/ElectricImpSampleCode/f0fb7f8bd04be009beeb5ee86dbd406a | |
const USERNAME = '...' | |
const PASSWORD = '...' | |
const ACCESS_TOKEN = '...' | |
const API_URL = 'api.electricimp.com' | |
const API_VER = '/v5/' |
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
// CONSTANTS | |
// Replace the 'USERNAME' and 'PASSWORD' values with your own | |
// Replace the 'ACCESS_TOKEN' value with one retrieved using 'products.js' at | |
// https://gist.github.com/ElectricImpSampleCode/f0fb7f8bd04be009beeb5ee86dbd406a | |
const USERNAME = '...' | |
const PASSWORD = '...' | |
const ACCESS_TOKEN = '...' | |
const API_URL = 'api.electricimp.com' | |
const API_VER = '/v5/' |
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
// CONSTANTS | |
// Replace the 'USERNAME' and 'PASSWORD' values with your own | |
const USERNAME = '...' | |
const PASSWORD = '...' | |
const API_URL = 'api.electricimp.com' | |
const API_VER = '/v5/' | |
// GLOBALS | |
var https = require('https'); | |
var products = []; |
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
// Constants for the OLED and the SSD1306 | |
const SSD1306_SETCONTRAST = "\x81"; | |
const SSD1306_DISPLAYALLON_RESUME = "\xA4"; | |
const SSD1306_DISPLAYALLON = "\xA5"; | |
const SSD1306_NORMALDISPLAY = "\xA6"; | |
const SSD1306_INVERTDISPLAY = "\xA7"; | |
const SSD1306_DISPLAYOFF = "\xAE"; | |
const SSD1306_DISPLAYON = "\xAF"; | |
const SSD1306_SETDISPLAYOFFSET = "\xD3"; | |
const SSD1306_SETCOMPINS = "\xDA"; |
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
// WEATHER UPDATE CLASS | |
#require "Darksky.class.nut:1.0.1" | |
const REFRESH_TIME = 900; | |
// AGENT FUNCTIONS | |
function sendForecast(unusedValue) { | |
request = weather.forecastRequest(myLongitude, myLatitude); | |
request.sendasync(forecastHandler); | |
} |
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
// CONSTANTS | |
const PLOTLY_USERNAME = "<your_username>"; | |
const PLOTLY_KEY = "<your_key>"; | |
const PLOTLY_TOKEN = "<your_token>"; | |
// GLOBAL VARIABLES | |
// 'stream' will hold the httpstream object we create in initiateStream() | |
stream <- null; | |
dataCount <- 0; |