Skip to content

Instantly share code, notes, and snippets.

View pavax's full-sized avatar

Patrick D. pavax

  • schaltstelle
  • Bern, Switzerland
View GitHub Profile
@pavax
pavax / gist:a6a425ee41beb4a6cd7770091b192ba5
Last active August 25, 2026 21:11
Kamstrup Omnipower Smart-Meter Readings using EspHome and Esp-now
# ESPHome for a Lolin S3 Mini on the HAN port of a Kamstrup Omnipower.
# Powered from the meter (HAN); a supercapacitor buffers energy — no battery.
# Reads DLMS telegrams (power/energy import+export) and sends them via
# ESP-NOW to the hub. Radio stays off until it is time to transmit.
# Capacitor check before metering: voltage too low → short sleep to recharge.
# Otherwise wait for a telegram (or timeout), send, then deep sleep until the next slot.
#
# LED: brief blue if capacitor is OK, red if voltage is too low, green after telegram, off in sleep.
# Flow: radio off → capacitor check → DLMS → ESP-NOW → sleep.
# Capacitor < ${min_capacitor_voltage}: sleep ${charging_sleep_duration_seconds}s immediately (capacitor charges, no radio).
@pavax
pavax / smart-plant-watering-mini-1.yaml
Last active May 9, 2025 23:42
smart-plant-watering-mini-1.yaml
substitutions:
name: "smart-plant-watering-mini-1"
friendly_name: "Smart Plant Watering Mini 1"
initial_sleep_duration_minutes: "120" # For how long (minutes) should the MCU sleep
initial_watering_wait_time_minutes: "240" # Time (minutes) to wait before watering the plant again
initial_min_moisture_level: "15" # Threshold that defines when to water a plant
initial_watering_time_seconds: "10" # How long should the watering process run (seconds)
initial_max_running_time_minutes: "5" # Max time (minutes) for the MCU to stay awake
battery_max: "8.2" # Battery voltage indicating 100%
battery_min: "6.6" # Battery voltage indicating 0%
@pavax
pavax / smart-plant-watering.yaml
Last active May 15, 2025 21:51
ESPHome Config for Plant Watering
substitutions:
friendly_name: "Smart Plant Watering 2"
name: "smart-plant-watering-2"
initial_sleep_duration_minutes: "60" # For how long (minutes) should the node sleep
initial_rewatering_wait_time_minutes: "240" # Time (minutes) to wait before watering the plant again
initial_min_moisture_level: "15" # Threshold that defines when to water a plant
initial_max_watering_time_seconds: "10" # How long should the watering process run (seconds)
initial_max_running_time_minutes: "5" # Max time (minutes) for the node to stay awake
battery_max: "4.1" # Battery voltage indicating 100%
battery_min: "3.3" # Battery voltage indicating 0%
@pavax
pavax / update-mkv.sh
Last active February 8, 2025 13:13
script to check for optical drive changes and update docker-compose files
#!/bin/sh
# Path to the Docker Compose file
DOCKER_COMPOSE_FILE="/volume2/mkv/makemkv-docker/docker-compose.yml"
find_device_paths_from_compose() {
echo "Searching for device paths in the Docker Compose file..."
device_path_sr=$(grep -o '/dev/sr[^:"]*' "$DOCKER_COMPOSE_FILE" | head -n1)
device_path_sg=$(grep -o '/dev/sg[^:"]*' "$DOCKER_COMPOSE_FILE" | head -n1)
@pavax
pavax / nsfw.oisd.nl
Created December 29, 2024 17:52
nsfw.oisd.nl having the ctag=user_child applied
This file has been truncated, but you can view the full file.
[Adblock Plus]
! Version: 202412291713
! Title: oisd nsfw
! Description: Block. Don't break.
! Syntax: Adblock Plus Filter List
! Entries: 329315
! Last modified: 2024-12-29T17:13:57+0000
! Expires: 1 hours
! License: https://github.com/sjhgvr/oisd/blob/main/LICENSE
@pavax
pavax / creative-stage-se-esphome.yaml
Created October 13, 2024 15:44
IR Transmitter Commands to Control the Creative Stage SE Soundbar using ESPHome
button:
- platform: template
name: "${name} Power"
on_press:
- remote_transmitter.transmit_nec:
address: 0xB683
command: 0xB24D
command_repeats: 1
- platform: template
acme-v01.api.letsencrypt.org
acme-staging.api.letsencrypt.org
acme-v02.api.letsencrypt.org
acme-staging-v02.api.letsencrypt.org
outbound1a.letsencrypt.org
outbound1b.letsencrypt.org
outbound1c.letsencrypt.org
outbound1d.letsencrypt.org
outbound1e.letsencrypt.org
outbound1f.letsencrypt.org
@pavax
pavax / natpmpc-transmission-update.sh
Last active June 13, 2026 08:31
Bash script to open a port using natpmpc and update the opened port in transmission-daemon
#!/bin/bash
# The gatway to send the natpmp commands
natpmp_ip="10.2.0.1"
# Path to the lock file
lock_file="/tmp/transmission_update.lock"
# Path to the Transmission settings.json file
settings_file="/etc/transmission-daemon/settings.json"
@pavax
pavax / udpbroadcastrelay
Last active July 30, 2024 21:17
udpbroadcastrelay freebsd service
#!/bin/sh
# How to use:
# Place this file in /usr/local/etc/rc.d/
# Make the file executable: chmod +x /usr/local/etc/rc.d/udpbroadcastrelay2
# Adjust the command_args to your needs
# Add udpbroadcastrelay_enable="YES" to /etc/rc.config
# Start using the command: service udpbroadcastrelay start
. /etc/rc.subr
@pavax
pavax / z2m_aqara_trv_external_temperature.yaml
Last active May 14, 2026 12:03
z2m_aqara_trv_external_temperature.yaml
blueprint:
name: Aqara TRV E1 External Temperature Control
description: >
This automation allows the Aqara TRV E1 Smart Radiator Thermostat to use temperature readings from an external sensor rather than its internal sensor. Whenever the temperature sensor reports a new value, it is sent to the TRV for more accurate climate control.
domain: automation
source_url: "https://gist.github.com/pavax/8d6ed250765d89cb281d4a1762b8d2e8"
input:
external_temp_sensor:
name: External Temperature Sensor