Skip to content

Instantly share code, notes, and snippets.

View tomoinn's full-sized avatar

Tom Oinn tomoinn

View GitHub Profile
blueprint:
domain: automation
name: Switch scenes with Philips Hue Dimmer Switch (RWL022 or RWL021)
description: >
Control custom scenes within HA in the same way the Hue dimmer switches work for
native Philips Hue scenes. If lights are on then the power button will cycle through
scenes, if they're off it'll try to start the most recently used scene. Off button
will turn off all lights in the most recently used scene's entity list, as will the
brightness up / down control.
from approxeng.task import task, resource, run
import time
@resource(name='lux')
def read_light_sensor():
sensor_reading = ...
return sensor_reading
# Create the motor board object, this will depend on the hardware
# fitted to your robot.
@tomoinn
tomoinn / bluetooth-pi-notes.txt
Last active October 7, 2018 20:28
Notes on setting up my Raspberry Pi for PiWars, no further explanation but might be helpful!
Install 4.15.9 according to https://www.raspberrypi.org/documentation/linux/kernel/building.md
SSH to pi, then...
sudo apt-get install git bc libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev -y
wget www.kernel.org/pub/linux/bluetooth/bluez-5.49.tar.xz
tar -xvf ./bluez-5.49.tar.xz
cd bluez-5.49/
wget https://gist.github.com/pelwell/c8230c48ea24698527cd/archive/3b07a1eb296862da889609a84f8e10b299b7442d.zip
unzip 3b07a1eb296862da889609a84f8e10b299b7442d.zip
"""
Python 3.6 library to interact with OVO Energy's REST API. This isn't an officially supported API
so this library may or may not continue to work. YMMV, don't blame me if it breaks etc etc.
Tom Oinn, 22nd May 2018
"""
import json
from datetime import datetime, timedelta
from http import HTTPStatus
@tomoinn
tomoinn / index.html
Created October 24, 2017 10:25
Quick flask based server. Put static stuff (index.html etc) in a directory 'static'
<html>
<head>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
</head>
<body>
<a href='/?action=yes'>Yes!</a>
<a href='/?action=no'>No!</a>
</body>
@tomoinn
tomoinn / rainbow_strip.cc
Created July 10, 2013 18:49
A bit of code to demonstrate the light strip from insomnialighting.com here - http://www.insomnialighting.com/catalog/index.php?main_page=product_info&cPath=6_4&products_id=8 using an arduino nano. Data and clock lines on the strip are connected to pins 11 and 13 of the nano respectively to make use of hardware SPI.
#include "LPD8806.h"
#include "SPI.h"
// Simple test for 260 (5 meters) of LPD8806-based RGB LED strip, this is a
// modified version of the original demo - it creates a rainbow, animates it
// and fades from black->colours->white->colours->black in a cycle, holding
// somewhat longer on the full colour, all while cycling the rainbow colours.
// This has been tested with a high density (260 LEDs / 5m) strip and a nano
// board, running from a 5V 10A PSU.