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
| import pi_switch | |
| from mylogger import logger | |
| byte0codeON = 0x55 | |
| byte0codeOFF = 0x54 | |
| groupToCodeMap = { | |
| 1: 0x15, | |
| 2: 0x45, | |
| 3: 0x51, |
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
| from flask import Flask, jsonify, request, render_template, abort | |
| from outletdefinitions import outlets | |
| import codesender | |
| app = Flask(__name__) | |
| @app.route("/Outlets/api/outlets", methods=["GET"]) | |
| def get_outlets(): | |
| return jsonify({"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
| # Examples on REST calls to the api | |
| # Replace localhost:5000 with the IP-address and port of the machine where the api is running | |
| # List all defined outlets (GET) | |
| curl -i http://localhost:5000/Outlets/api/outlets | |
| # Turn on power for outlet 1 in group 2 | |
| curl -i -H "Content-Type: application/json" -X PUT -d '{"state":"on"}' http://localhost:5000/Outlets/api/outlets/2/1 | |
| # Turn on power for outlet 3 in group 1 |
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 time | |
| class MQTTpublisher: | |
| brokerIP = "" | |
| brokerPort = 0 | |
| def __init__(self,brokerIP,brokerPort): | |
| self.brokerIP = brokerIP | |
| self.brokerPort = brokerPort |
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
| from radiomessage import RadioMessage | |
| from measurementtype import MeasurementType | |
| from pi_switch import RCSwitchReceiver | |
| class RadioListener: | |
| validMeasurementTypes = [] | |
| previousValue = 0 | |
| numIdenticalValuesInARow = 0 | |
| latestMessage = None | |
| receiver = RCSwitchReceiver() |
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
| # | |
| # A propagator node in an MQTT System | |
| # It listens on messages/chirps via 433MHz radio and translates them to | |
| # MQTT packages that are published over TCP/IP to a broker | |
| # | |
| from measurementtype import MeasurementType | |
| from MQTTpublisher import MQTTpublisher | |
| from radiolistener import RadioListener | |
| import time |
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 python | |
| from propagatornode.propagatorapplication import PropagatorApplication | |
| if __name__ == '__main__': | |
| wiringPiPinForReceiver = 2 | |
| brokerIP = "192.168.1.16" | |
| brokerPort = 1883 | |
| app = PropagatorApplication(wiringPiPinForReceiver,brokerIP,brokerPort) | |
| app.run() |
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
| // | |
| // An Arduino sketch for an IoT node that broadcasts sensor values via | |
| // 433 MHz radio signals | |
| // The RCSwitch library is used for the transmissions | |
| // The Narcopleptic library is used for power save during delay | |
| // Sensor values are fetched from an BPM180/085 sensor via i2C | |
| // | |
| #include <Wire.h> | |
| #include <Adafruit_BMP085.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
| void setup() { | |
| size(600, 300, P3D); | |
| } | |
| void draw() { | |
| background(100); | |
| lights(); | |
| stroke(10); | |
| float rotationX = map(mouseX,0,width,0,2*PI); |