Skip to content

Instantly share code, notes, and snippets.

View OttoWinter's full-sized avatar
🏠

Otto Winter OttoWinter

🏠
View GitHub Profile
@OttoWinter
OttoWinter / README.md
Last active February 7, 2018 17:26
Grouped Lights

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:
"""
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
#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 {
#include "esphomelib/application.h"
#ifdef ARDUINO_ARCH_ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
using namespace esphomelib;
@OttoWinter
OttoWinter / 0migrator.md
Last active May 19, 2019 04:21
Lovelace Migration Script

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>
@OttoWinter
OttoWinter / cron-match.py
Last active October 4, 2018 14:51
Cron Next Matcher
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)
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" ]
---
# 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: