Skip to content

Instantly share code, notes, and snippets.

View erkr's full-sized avatar

Eric Kreuwels erkr

View GitHub Profile
@erkr
erkr / Tuya TS0001 Wall Switches no metering.py
Last active January 15, 2024 10:07
Custom Quirk for Aubess (Tuya TS0001 _TZ3000_46t1rvdu)
"""Aubess / tuya TS0001 Wall Switches."""
# I bought some Aubess (Tuya TS0001 _TZ3000_46t1rvdu) devices on Ali
# The signature is recognized as a Tuya TS0001 device with power metering support, but it doesn report any values.
# This custom quirk makes it a simple switch device with the option to configure the power on behavior
from zigpy.profiles import zgp, zha
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
@erkr
erkr / Tuya TS000F Wall Switches.py
Created July 17, 2023 18:09
ZHAQuirk for the tuya switch with power monitoring _TZ3000_xkap8wtb model TS000F.
"""tuya TS000F Wall Switches."""
# This quirk scales both the current and summation readout, and it changes the device from a light into a switch
# Note: this quirk is similar to the offical TS000x quirks, except that this device has quite a different signature.
# That includes a unknown cluster ID 0x1888 that I filtered out.
from zigpy.profiles import zgp, zha
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
@erkr
erkr / fetch_lovelace_config.py
Last active March 29, 2024 18:09
Don't start using this script! Open the link for a better solution. This gist is deprecated! Instead of parsing the dashboard for information included in a custom:datetime-card, I found a way to move all information to the back-end and populate the date-time card using auto-entities!! See: https://github.com/a-p-z/datetime-card/issues/25#issueco…
# All credits how to use websockets to retrieve the lovelace configuration goes to https://github.com/qui3xote:
# https://github.com/custom-components/pyscript/discussions/272#discussioncomment-1709728
# This example adds a service that itteratively looks-up all custom:datetime-card based cards in a particular dashboard (where optionally a specific view can be specified)
# There it evaluates all entities if they exceed the max time configured in that card and then send a notification for them
#
# Note this latest version will itterate through all embedded cards (ie vertical stacks, confditional etc)
#
# MIT license by Eric Kreuwels
import json
@erkr
erkr / AutoShutdown.sh
Created May 15, 2022 12:58
TrueNAS Auto shutdown script
#!/bin/bash
# AutoShutdown.sh (c)2022, MIT license, by Eric Kreuwels
# USAGE: AutoShutdown [test|echo]
#
# Shutdown TrueNas systems when idle for a defined timeout period (default 1800 seconds),
# Active during a configurable monitoring timeframe (default between 01:00:00 to 06:30:00).
# Run "AutoShutdown test" to just evaluate the idle checks
# Run "AutoShutdown echo" to echo to stdout instead of the log file
# For normal operation add a "post init script" in truenas: bash /<path>/AutoShutdown.sh&
# Idle is defined as:
@erkr
erkr / persistent_sunset_offset_actions.yaml
Created May 12, 2022 10:40
Home Assistant Blueprint for 'persistent' Sunset with a time offset triggered actions
# Author Eric Kreuwels, Copyright 2022, publiced under the free MIT license conditions
blueprint:
name: Actions at Sunset Offset
description: Persistant offset based actions around sunset. These actions can be any sequence including checking additional conditions if you like
domain: automation
input:
time_shift:
name: Time Shift
description: Using time shift around Sunrise. A negative value is earlier, a positive value is later.
default: "-00:01:00"
@erkr
erkr / persistent_sunrise_offset_actions.yaml
Created May 12, 2022 10:40
Home Assistant Blueprint for 'persistent' Sunrise with a time offset triggered actions
# Author Eric Kreuwels, Copyright 2022, publiced under the free MIT license conditions
blueprint:
name: Actions at Sunrise Offset
description: Persistant offset based actions around sunrise. These actions can be any sequence including checking additional conditions if you like
domain: automation
input:
time_shift:
name: Time Shift
description: Using time shift around Sunrise. A negative value is earlier, a positive value is later.
default: "-00:01:00"
@erkr
erkr / persistent_sunset_elevation_actions.yaml
Created May 12, 2022 10:39
Home Assistant Blueprint for 'persistent' Sunset elevation triggered actions
# Author Eric Kreuwels, Copyright 2022, publiced under the free MIT license conditions
blueprint:
name: Actions at Sunset elevation
description: Persistant elevation based actions around sunset. These actions can be any sequence including checking additional conditions if you like
domain: automation
input:
elevation_shift:
name: Elevation Shift
description: Using an elevation angle of the sun relative to the horizon; a positive angle is above the horizon. Angles between 0 and -3 degrees are in the twilight zone
default: 0.0
@erkr
erkr / persistent_sunrise_elevation_actions.yaml
Created May 12, 2022 10:38
Home Assistant Blueprint for 'persistent' Sunrise elevation triggered actions
# Author Eric Kreuwels, Copyright 2022, publiced under the free MIT license conditions
blueprint:
name: Actions at Sunrise elevation
description: Persistant elevation based actions around sunrise. These actions can be any sequence including checking additional conditions if you like
domain: automation
input:
elevation_shift:
name: Elevation Shift
description: Using an elevation angle of the sun relative to the horizon; a positive angle is above the horizon. Angles between 0 and -3 degrees are in the twilight zone
default: 0.0
@erkr
erkr / zha-ikea-symfonisk-round-sound-controller.yaml
Created May 12, 2022 10:13
Home Assistant Blueprints: ZHA version for controlling media players with an Ikea Symfonisk
blueprint:
# Author Eric Kreuwels, Copyright 2022, publices under the free MIT license conditions
# This blueprint was inspired by:
# https://community.home-assistant.io/t/zha-ikea-symfonisk-sound-controller-for-media-the-spinny-one/266130
# This version requires to recreate your automations that are based on the version above (new options and therefor not compatible)
# Changes compared to the one that inspired me:
# moved from raw ZHA events to ZHA Symfonisk Device events (raw event attributes changed to often to keep it working)
# added configuration inputs for changing the volume delay and number of volume steps
# added option to either pause (default) or mute for single press action
# restricted the player selection to entities only