This file contains hidden or 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
| <!DOCTYPE html> | |
| <html ng-app="myApp" style="height: 100%"> | |
| <head> | |
| <script data-require="[email protected]" data-semver="1.4.8" src="https://code.angularjs.org/1.4.8/angular.js"></script> | |
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.css" /> | |
| <script src="/static/Controller.js"></script> | |
| </head> | |
| <body style="height: 100%"> |
This file contains hidden or 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
| var myApp = angular.module('myApp', []); | |
| myApp.controller('OutletController', ['$scope', '$http', function($scope, $http) { | |
| $scope.header = 'Outlets'; | |
| var getOutletInfo = function() { | |
| $http.get("api/outlets").then(function(response) { | |
| var outlets = response.data.outlets; | |
| $scope.outlets = outlets; |
This file contains hidden or 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
| #!/bin/sh | |
| # from http://blog.scphillips.com/posts/2013/07/getting-a-python-script-to-run-in-the-background-as-a-service-on-boot/ | |
| ### BEGIN INIT INFO | |
| # Provides: remotecontrol | |
| # Required-Start: $remote_fs $syslog | |
| # Required-Stop: $remote_fs $syslog | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: A service for a web server that handles remote controlled outles |
This file contains hidden or 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 paho.mqtt.client as mqtt | |
| def on_connect(client, userdata, flags, rc): | |
| print("Connected with result code "+str(rc)) | |
| client.subscribe("Hellos/+") | |
| def on_message(client, userdata, msg): | |
| print(msg.topic+" "+str(msg.payload)) | |
| client = mqtt.Client() |
This file contains hidden or 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
| // | |
| // This is a minimal example on MQTT publish and subscribe | |
| // from an ESP8266 board to an MQTT broker (I have used a local Mosquitto running on a Raspberry Pi) | |
| // This example uses the Arduino-MQTT library (https://github.com/256dpi/arduino-mqtt) | |
| // Install it in the Arduino IDE before compiling the sketch | |
| #include <ESP8266WiFi.h> | |
| #include <MQTTClient.h> | |
| #include "WIFI_and_broker_parameters.h" |
This file contains hidden or 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
| // | |
| // This is a minimal example on MQTT publish and subscribe from an ESP8266 board | |
| // to an MQTT broker (I have used a local Mosquitto running on a Raspberry Pi) | |
| // This example uses the PubSub client library (https://github.com/knolleary/pubsubclient) | |
| // Install it in the Arduino IDE before compiling the sketch | |
| #include <ESP8266WiFi.h> | |
| #include <PubSubClient.h> | |
| #include "WIFI_and_broker_parameters.h" |
This file contains hidden or 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
| // | |
| // This is an example on MQTT publish from an ESP8266 board | |
| // to an MQTT broker (I have used a local Mosquitto running on a Raspberry Pi) | |
| // This example uses the PubSub client library (https://github.com/knolleary/pubsubclient) | |
| // Install it in the Arduino IDE before compiling the sketch | |
| // Sensor values are fetched from an indoor DHT22 sensor and an outdoor DHT22 sensor | |
| #include <ESP8266WiFi.h> | |
| #include <PubSubClient.h> |
This file contains hidden or 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 paho.mqtt.client as mqtt | |
| import datetime | |
| def on_connect(client, userdata, flags, rc): | |
| print("Connected with result code "+str(rc)) | |
| client.subscribe("Home/#") | |
| def on_message(client, userdata, msg): | |
| print(str(datetime.datetime.now()) + ": " + msg.topic + " " + str(msg.payload)) |
This file contains hidden or 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
| void loop() | |
| { | |
| if ( firstTime || (millis() - lastTime > SECONDS_BETWEEN_MEASUREMENTS*1000) ) | |
| { | |
| firstTime = false; | |
| lastTime = millis(); | |
| if (!mqttClient.connected()) | |
| { | |
| connectToWiFiAndBroker(); |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| import paho.mqtt.client as mqtt | |
| import datetime | |
| from pymongo import MongoClient | |
| def on_connect(client, userdata, flags, rc): | |
| print("Connected with result code "+str(rc)) | |
| client.subscribe("Home/#") |