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
var myApp = angular.module('myApp', []); | |
myApp.controller('SRChannelsController', ['$scope', '$http', function($scope, $http) { | |
var promise = $http.get("http://api.sr.se/api/v2/channels/?format=json&pagination=false&filter=channel.channeltype&filtervalue=Riks"); | |
promise.then(function(response) { | |
var channels = response.data.channels; | |
$scope.channels = channels; |
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 RPi.GPIO as GPIO | |
from flask import Flask, jsonify, abort, request, render_template | |
from relaydefinitions import relays, relayIdToPin | |
app = Flask(__name__) | |
GPIO.setmode(GPIO.BCM) | |
relayStateToGPIOState = { | |
'off' : GPIO.LOW, |
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
relays = [ | |
{ 'id' : 1, 'name' : 'Window lamp', 'state' : 'off'}, | |
{ 'id' : 2, 'name' : 'Floor lamp', 'state' : 'off'}, | |
{ 'id' : 3, 'name' : 'TV etc', 'state' : 'off'}, | |
{ 'id' : 4, 'name' : 'Guitar equipment', 'state' : 'off'} | |
] | |
relayIdToPin = { | |
1 : 24, | |
2 : 25, |
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
@app.route('/WebRelay/', methods=['GET']) | |
def index(): | |
return render_template('Index.html'); |
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
var myApp = angular.module('myApp', []) | |
.config(function($interpolateProvider) { | |
$interpolateProvider.startSymbol('[[').endSymbol(']]'); | |
}); | |
var addImageToRelayObjects = function(relayObjects) { | |
for (var i=0; i < relayObjects.length; i++) { | |
var relay = relayObjects[i]; | |
if (relay.state == 'on') { | |
relay.image = '/static/on_button.gif'; |
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
<!DOCTYPE html> | |
<html ng-app="myApp"> | |
<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> | |
<link rel="stylesheet" href="/static/style.css" /> | |
</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
// Depends on the RCSwitch library | |
// https://github.com/sui77/rc-switch | |
#include "RCSwitch.h" | |
// Light measurement goes to A0 pin | |
#define LIGHT_IN 0 | |
// A unique ID (4 bits, 0-15) for each device so that the receiver | |
// understands which device sent what message | |
#define ARDUINO_ID 3 |
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
# Uses pi_switch from https://github.com/lexruee/pi-switch-python | |
# See pi_switch readme for details on setup | |
from pi_switch import RCSwitchReceiver | |
import time | |
receiver = RCSwitchReceiver() | |
receiver.enableReceive(2) | |
acceptedTypes = { 1 : "Light", 2 : "Temp [C]", 3: "Humidity [%]" } |
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
#include "RCSwitch.h" | |
#include <DHT.h> | |
#define LIGHT_IN 0 // Light measurement goes to A0 pin | |
#define DHTPIN 2 // Signal in from DHT11 goes to digital pin 2 | |
#define DHTTYPE DHT11 | |
// Unique ID:s (4 bits, 0-15) for each measurement type so that the receiver | |
// understands how to interpret the data on arrival | |
#define LDR_MEASUREMENT_ID 1 |
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
// Depends on the RCSwitch library https://github.com/sui77/rc-switch | |
// and the DHT sensor-, OneWire- and DallasTemperature libraries | |
#include "RCSwitch.h" | |
#include <DHT.h> | |
#include <OneWire.h> | |
#include <DallasTemperature.h> | |
// Unique ID:s (4 bits, 0-15) for each measurement type so that the receiver | |
// understands how to interpret the data on arrival |
OlderNewer