Skip to content

Instantly share code, notes, and snippets.

HomeKitSwitchComponent

This component allows you to publish a custom payload to a custom topic(s) for an ESPHome switch component.

This makes it easier to integrate with HomeKit which expects a 0 or 1 instead of ON/OFF for switches.

Example configuration for publishing a relay's state as 0 or 1 to a custom topic which is compatible with mqtt2homekit (more info):

esphome:
https://docs.google.com/presentation/d/1LXb3QCVqw7285MVvEig_xoy5YUmsSeJY50eL6IzcJi4/edit?usp=sharing
This file has been truncated, but you can view the full file.
/*
OpenLayers.js -- OpenLayers Map Viewer Library
Copyright (c) 2006-2015 by OpenLayers Contributors
Published under the 2-clause BSD license.
See https://raw.githubusercontent.com/openlayers/ol2/master/license.txt for the full text of the license, and https://raw.githubusercontent.com/openlayers/ol2/master/authors.txt for full list of contributors.
Includes compressed code under the following licenses:
@davea
davea / README.md
Created June 19, 2019 12:27
Raspbian set up

raspbian_setup

Vagrantfile to make setting up a headless Raspberry Pi a bit easier.

Usage

SSID=mywifi WPAPASSPHRASE=passphrase HOSTNAME=office \
IMG=2016-11-25-raspbian-jessie-lite.img vagrant up

Will create office-2016-11-25-raspbian-jessie-lite.img which is set up to

@davea
davea / reload_chrome.sh
Created July 19, 2017 10:25
Simple script to reload tabs in Chrome (on macOS) that match a certain keyword.
#!/bin/sh
set -e
osascript<<EOF
tell application "Google Chrome"
set windowList to every window
repeat with aWindow in windowList
set tabList to every tab of aWindow
repeat with atab in tabList
@davea
davea / main.cpp
Last active June 16, 2017 19:32
Minimal case of interrupt handler causing crash on ESP8266. Compile with `ENABLE_WIFI` to see the crash. For https://github.com/puuu/ESPiLight/pull/9
#include <Arduino.h>
#include <ESPiLight.h>
#ifdef ENABLE_WIFI
#include <ESP8266WiFi.h>
#define WIFI_SSID "myssid"
#define WIFI_PSK "mypassphrase"
#endif
@davea
davea / argh.py
Created January 31, 2017 14:02 — forked from dracos/argh.py
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('args', nargs='*') # from __init__.py execute()
parser.add_argument('args', nargs='+') # from base.py LabelCommand add_arguments
print(parser.parse_args(['foo1', 'foo2', 'foo3', 'foo4']))
# Outputs Namespace(args=['foo4'])
#!/bin/bash
set -e
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd | sed -e 's/\/bin$//' )/.."
FROM="$DIR/fixmystreet/conf/general-$1.yml"
TO="$DIR/fixmystreet/conf/general.yml"
[[ -e $FROM ]] || echo "${FROM} doesn't exist"
CREATE EXTENSION plperlu;
CREATE OR REPLACE FUNCTION read_rabx(text, text) RETURNS boolean LANGUAGE plperlu IMMUTABLE AS $$
use IO::String;
use utf8;
my ($extra, $key) = @_;
sub netstring_rd ($) {
my ($h) = @_;
@davea
davea / ssdp.py
Last active December 15, 2015 23:01 — forked from dankrause/ssdp.py
Tiny python SSDP discovery library with no external dependencies - Python 2 & 3 compatible
# Copyright 2014 Dan Krause
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,