Skip to content

Instantly share code, notes, and snippets.

@asciiphil
asciiphil / README.md
Created Dec 14, 2015
OpenHAB Alarm Definition
View README.md

This defines a rule that allows for a "sunrise" style alarm. Basically, you trigger it by setting the Alarm_Trigger item to a value that defines parameters for the alarm:

  • duration gives the length of the alarm in minutes
  • light gives the minimum and maximum brightness values over the course of the alarm, e.g. light=0,75.
  • temp gives the range of color temperatures over the course of the alarm, e.g. temp=2700,5000

Add dimmers to the Alarm_Dimmers group. Add Number items for color temperature to the Alarm_Temps group. Any switches in the Alarm_Switches group will be turned on at the end of the alarm.

The Alarm_Running item serves as a UI element to halt a running alarm. Just turn it OFF while the alarm is running,

View randspace.py
#!/usr/bin/python
import random
import string
UNAMBIGUOUS_LETTERS = list(set(string.ascii_lowercase) - set('ilou'))
def randid_worker(params):
"""PARAMS is a collection of (SET, COUNT) pairs. The function returns
a collection of COUNT_0 + COUNT_1 + ... COUNT_n items, drawn from the
View randspace.py
#!/usr/bin/python
import random
import string
UNAMBIGUOUS_LETTERS = list(set(string.ascii_lowercase) - set('ilou'))
def randid():
"""Creates a random ID space with three modified
base32 characters and one number in random order for
@asciiphil
asciiphil / MPL115A2.py
Last active Apr 10, 2021
Python class for communicating with a MPL115A2 I2C digital barometer/temperature sensor. Uses the Adafruit_I2C class from the Adafruit Raspberry Pi Python Code: https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code .
View MPL115A2.py
#!/usr/bin/python
# Author: Phil! Gold <phil_g@pobox.com>
# License: CC0 Waiver http://creativecommons.org/publicdomain/zero/1.0/
import time
from Adafruit_I2C import Adafruit_I2C
class _MPL115A2_Register:
@asciiphil
asciiphil / tirex-queue
Last active Dec 19, 2015
Script for rerendering all of my tirex tiles.
View tirex-queue
#!/bin/sh
# Extent of the rendering database; tiles outside this are pointless.
latlon="lon=-125.0841,-66.9251 lat=24.2520,49.3845"
for map in cutouts; do
# rerender everything that's expired.
for z in `seq 2 16`; do
prio=$(calc 70 - $z)
tirex-batch -f 'exists;older(/var/lib/tirex/tiles/planet-import-complete)' -p $prio $latlon map=$map z=$z