Skip to content

Instantly share code, notes, and snippets.

View achterberg's full-sized avatar

David Achterberg achterberg

View GitHub Profile
@achterberg
achterberg / alertPanic.py
Created November 23, 2017 16:57
(Indigodomotics) Panic Alert
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*
# https://stackoverflow.com/questions/3498313/how-to-trigger-from-python-playing-of-a-wav-or-mp3-audio-file-on-a-mac
import subprocess
import time
audio_file = "/Users/Alerts/Evacuation Sound.mp3"
# save current source, connect speakers, set volume
@achterberg
achterberg / doorAlertNotification.py
Last active November 23, 2017 16:54
(Indigodomotics) Door Alert Notification
#!/usr/bin/env python
# -*- coding: utf-8 -*
# Text to speech conversion using python
# http://codesync.in/2017/04/22/text-speech-conversion-using-python/
# https://stackoverflow.com/questions/35332375/nsspeechsynthesizer-saving-to-url
from AppKit import NSSpeechSynthesizer
import time
### Keybase proof
I hereby claim:
* I am achterberg on github.
* I am achterberg (https://keybase.io/achterberg) on keybase.
* I have a public key ASA3ssY4HgqeqZXNDrlzzPJ8AhfSF3myTnzAIIS5v2LXHQo
To claim this, I am signing this object:
@achterberg
achterberg / f.lux
Created March 9, 2015 04:24
(Indigodomotics) Calculate f.lux
# attempt to match the K values of f.lux (https://justgetflux.com) to set Hue lights
import datetime
from datetime import date
import math
now = datetime.datetime.now()
today = date.today()
sriseOffset = indigo.server.calculateSunrise(today) - datetime.timedelta(minutes=85)
ssetOffset = indigo.server.calculateSunset(today) - datetime.timedelta(minutes=30)
@achterberg
achterberg / RandomLightOn
Created February 21, 2015 21:56
(Indigodomotics) Turn on a random light for a random duration
# run as external script
import indigoAttachments
from random import randint
import random
import sys
import datetime
import time
indigoAttachments.specialLog("Imported the IOM to run randomlighton.py")
@achterberg
achterberg / snippets
Last active August 29, 2015 14:15
(Indigodomotics) Various python script snippets
# turn on a device if another device is on
# if Bedroom Desk light is on, turn on the Bedroom Lamp
if (indigo.devices[123456789].onState) : indigo.device.turnOn(987654321)
# schedule python jobs to execute only once in the future
newruntime = (datetime.datetime.now() + datetime.timedelta(minutes=5)).strftime("%H:%M %d.%m.%Y")
command = 'echo " python mainprog.py" | at ' + newruntime # replace mainprog.py
os.system(command)
@achterberg
achterberg / cheerlightstoindigo
Created February 21, 2015 21:27
(Indigodomotics) Set Hue light color to CheerLights (http://www.cheerlights.com) color
import sys
import random
import struct
import urllib2
red = {'red':'ff0000', 'red 2':'ee0000', 'red 3':'cd0000', 'red 4':'8b0000', 'crimson':'dc143c', 'dark red':'8b0000', 'dark salmon':'e9967a', 'indian red':'cd5c5c', 'indian red 1':'ff6a6a', 'indian red 2':'ee6363', 'indian red 3':'cd5555', 'indian red 4':'8b3a3a', 'light coral':'f08080', 'light salmon':'ffa07a', 'light salmon 2':'ee9572', 'light salmon 3':'cd8162', 'light salmon 4':'8b5742', 'salmon':'fa8072', 'salmon 1':'ff8c69', 'salmon 2':'ee8262', 'salmon 3':'cd7054', 'salmon 4':'8b4c39', 'coral':'ff7f50', 'coral 1':'ff7256', 'coral 2':'ee6a50', 'coral 3':'cd5b45', 'coral 4':'8b3e2f', 'firebrick':'b22222', 'tomato':'ff6347', 'orange red':'ff4500', 'feldspar':'d19275', 'flesh':'f5ccb0', 'scarlet':'8c1717', 'free speach red':'c00000'}
green = {'green':'008000', 'green 1':'00ff00', 'green 2':'00ee00', 'green 3':'00cd00', 'green4':'008b00', 'chartreuse':'7fff00', 'chartreuse 2':'76ee00', 'chartreuse 3':'66cd00', 'chartreuse 4':'458b00', 'dark cyan':'008b
@achterberg
achterberg / indigotoslack
Created February 21, 2015 05:08
(Indigodomotics) Send messages from Indigo to Slack
import urllib2
theVar = indigo.variables[1234567890]
text = "%s set to %sK" % (theVar.name, theVar.value)
# theVar = indigo.devices[1234567890]
# text = "Device %s is now %s" % (theVar.name, theVar.onState)
# theVar = indigo.schedules[1234567890]
# text = "%s" % theVar.name