Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠

Otto Winter OttoWinter

🏠
View GitHub Profile
View esp06.yaml
---
# esp06: Yet unused Sonoff POW R2
#
# This ESPHome code is used on a Sonoff POW R2.
# It is used to detect if my Dryer is running.
# It exposes a lot of information, including an
# additional binary sensor. This allows easy
# automations from Home Assistant.
#
esphome:
View Dockerfile
ARG BUILD_FROM
FROM $BUILD_FROM
ENV LANG C.UTF-8
# Copy data for add-on
COPY run.sh /
RUN chmod a+x /run.sh
CMD [ "/run.sh" ]
@OttoWinter
OttoWinter / cron-match.py
Last active Oct 4, 2018
Cron Next Matcher
View cron-match.py
from datetime import datetime, timedelta
import pytz
tz = pytz.timezone('Europe/Vienna')
def _lower_bound(cmp, arr):
# Return the first value in arr greater or equal to cmp
# Return None if no such value exists
# If arr were sorted, this could of course be done in log(n)
return next((x for x in arr if x >= cmp), None)
@OttoWinter
OttoWinter / 0migrator.md
Last active May 19, 2019
Lovelace Migration Script
View 0migrator.md

Home Assistant Lovelace Migrator

Do you want to try out this experimental (!) new lovelace UI stuff in Home Assistant but don't want to migrate your entire configuration? This script is here to help! It reads in your Home Assistant configuration (specifically the group: section) and creates a matching ui-lovelace.yaml file in your Home Assistant configuration folder (of course backing up any previous file at that path).

To use this script, you first need to have python and home assistant installed where you plan to run this script. Do so using virtual environments and the pip3 install -U homeassistant command. Then copy below file to lovelace_migrate.py (any location should work) and run:

python3 lovelace_migrate.py -c <PATH_TO_HASS_CONFIG_DIR>
View main.cpp
#include "esphomelib/application.h"
#ifdef ARDUINO_ARCH_ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
using namespace esphomelib;
View main.cpp
#define NUM_LEDS 60
class FastLEDLightOutput : public Component, public LightOutput {
public:
FastLEDLightOutput() {
// supports brightness and RGB
traits_ = LightTraits(true, true, false);
}
const LightTraits &get_traits() const override {
View konnected.py
"""
Support for Konnected devices.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/konnected/
"""
import logging
import hmac
import voluptuous as vol
@OttoWinter
OttoWinter / README.md
Last active Feb 7, 2018
Grouped Lights
View README.md

Grouped Lights

Based off of the excellent work over at https://gist.github.com/jjensn/83dd60d96330bbf66e58dfae336187bf

This component allows lights to be grouped together and supports all of Home Assistant's features such as effects and color temperatures. The "child" lights can still be used as normal though as this component just forwards all calls to all of the children and uses the first active child light for the group state.

In order to use this, first copy the attached code to a file custom_components/light/grouped_light.py in your configuration folder. Then, specify all of your grouped lights like this:

light:
You can’t perform that action at this time.