Skip to content

Instantly share code, notes, and snippets.

@balloob
balloob / CLA.md
Last active September 27, 2018 09:19 — forked from pjcozzi/CLA.md
CLA for Apache 2.0 license

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I have the right to submit it under the Apache 2.0 license; or

(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the Apache 2.0 license; or

@balloob
balloob / async_logger.py
Last active December 16, 2016 07:39
Async friendly logger
class AsyncFileHandler():
def __init__(self, loop, handler):
"""Initialize async logging file handle."""
self.handler = handler
self.loop = loop
self._queue = asyncio.Queue(loop=loop)
self._thread = threading.Thread(target=self._process)
def start_thread(self):
"""Start thread for processing."""
@balloob
balloob / spectacles.py
Last active November 13, 2016 18:34
Track spectacle bots in Home Assistant https://home-assistant.io
"""
Component to track where spectacles are being sold.
To install:
- Install Home Assistant (duh): https://home-assistant.io
- Add this file as <config dir>/custom_components/sensor/spectacles.py
- Add to configuration.yaml:
sensor:
platform: spectacles
@balloob
balloob / release_the_kraken.py
Created September 25, 2016 19:33
Stress test Home Assistant via the HTTP api
from multiprocessing.dummy import Pool
import sys
import time
from homeassistant import remote
# Docs: remote.API(host, [password], [port], [use_ssl])
api = remote.API('127.0.0.1')
start_time = time.time()

Keybase proof

I hereby claim:

  • I am balloob on github.
  • I am balloob (https://keybase.io/balloob) on keybase.
  • I have a public key whose fingerprint is BBAD 245E 7174 B2E5 AD56 CBFB 322A D3E1 BB02 7C65

To claim this, I am signing this object:

@balloob
balloob / home-assistant.ipynb
Last active October 5, 2023 10:38
Jupyter Notebook connecting to Home Assistant
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@balloob
balloob / config.h
Last active July 13, 2023 07:40
ESP8266 sketch to control a Whynter ARC-110WD portable air conditioner and monitor temperature using MQTT, infrared transmitter, DHT22. For a list of possible IR codes see https://docs.google.com/spreadsheets/d/1dsr4Jh-nzC6xvSKGpLlPBF0NRwvlpyw-ozg8eZU813w/edit#gid=0
#define wifi_ssid "YOUR_WIFI_NAME"
#define wifi_password "YOUR_WIFI_PASSWORD"
#define mqtt_server "MQTT_SERVER"
#define mqtt_user "MQTT_USER"
#define mqtt_password "MQTT_PASS"
#define ac_topic "device/study_room/ac"
#define temperature_topic "device/study_room/temperature"
#define humidity_topic "device/study_room/humidity"
@balloob
balloob / MQTT_ESP8266_temperature_humidity.ino
Created June 20, 2016 04:11
Sketch for the ESP8266 to publish temperature and humidity values received from a DHT22 to MQTT
// Get ESP8266 going with Arduino IDE
// - https://github.com/esp8266/Arduino#installing-with-boards-manager
// Required libraries (sketch -> include library -> manage libraries)
// - PubSubClient by Nick ‘O Leary
// - DHT sensor library by Adafruit
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <DHT.h>
@balloob
balloob / sensor_example.py
Last active November 23, 2021 16:31
Example platforms and automation component for Home Assistant
"""
Copy this file to <config_dir>/example/sensor.py
Add to your configuration.yaml:
sensor:
platform: example
"""
from homeassistant.const import TEMP_CELSIUS
from homeassistant.helpers.entity import Entity
@balloob
balloob / mqtt.py
Last active December 1, 2016 18:35
Home Assistant light/mqtt.py which turns on based on brightness being set.
"""
Support for MQTT lights.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.mqtt/
"""
import logging
from functools import partial
import homeassistant.components.mqtt as mqtt