Skip to content

Instantly share code, notes, and snippets.

View wolph's full-sized avatar

Rick van Hattem wolph

View GitHub Profile
@wolph
wolph / lights.yaml
Last active April 11, 2024 01:27
ESPHome Sonoff TX Ultimate T5-3C-86 Custom button component
light:
- platform: neopixelbus
type: GRB
variant: WS2812
pin: GPIO1
num_leds: 1
name: "NeoPixel 1"
internal: true
- platform: neopixelbus
type: GRB
@wolph
wolph / colortest.py
Last active March 30, 2024 02:44
Testing 256 color shells using background colors and automatic shell width detection
#!/usr/bin/env python
from __future__ import print_function
import os
import shutil
import subprocess
def get_width(default=80):
'''Attempt to detect console width and default to 80'''
esphome:
name: plant_moisture
platform: ESP32
board: esp32dev
wifi:
ssid: "spam"
password: "eggs"
# Enable logging
#!/usr/bin/env python3
'''
A very simple kubernetes secrets dump tool. You can use it like this:
# kubectl get secret -o yaml -A | python decode_secrets.py
'''
import sys
import yaml
import base64
@wolph
wolph / dreamscreen_sidekick_emulator.py
Last active January 16, 2024 20:12
This script emulates the Dreamscreen sidekick and displays the output on your screen. It requires a shell that supports full-rgb ansi. More info can be found here: http://dreamscreen.boards.net/post/6271/thread
#!/usr/bin/env python
import enum
import types
import aioudp
import struct
import asyncio
import blessings
from datetime import datetime
@wolph
wolph / backfill_mindergas.py
Created January 9, 2024 02:46
Upload historical data from InfluxDB to mindergas.nl
'''
Use an influxdb query like this to fetch the data and store it as `meterstanden.csv`:
```
SELECT max("value") FROM "m3" WHERE ("entity_id"::tag = 'gas_consumption') AND $timeFilter GROUP BY time(1d) fill(linear)
```
'''
import pandas as pd
import json
import requests
import progressbar
@wolph
wolph / aida64_prometheus_exporter.py
Last active December 18, 2023 10:27
This prometheus exports all of your AIDA64 data to a Prometheus server so you can chart all of them using Grafana: https://grafana.com/grafana/dashboards/11339
import re
import mmap
import typing
import hashlib
import logging
import argparse
import datetime
import ipaddress
import dataclasses
import xml.etree.cElementTree as ET
@wolph
wolph / barman_exporter.conf
Last active December 6, 2023 18:50
Prometheus exporter for barman
# vim: set ft=dosini:
# Supervisord config for the barman exporter
[program:barman_exporter]
environment=PATH=/usr/local/bin:%(ENV_PATH)s
command=/usr/local/bin/env python3 /var/barman/barman_exporter.py
user=barman
autostart=true
stopasgroup=true
killasgroup=true
@wolph
wolph / hcsr04.ino
Created December 30, 2018 18:59
Simple arduino HC-SR04 (HCSR04) distance detection using interrupts for low latency measurements
#include <Arduino.h>
// Uses https://github.com/PaulStoffregen/TimerOne for sending on a regular interval
#include <TimerOne.h>
// ECHO pin, needs to be a pin that supports interrupts!
#define ULTRASONIC_PIN_INPUT 2
// TRIG pin, can be any output pin
#define ULTRASONIC_PIN_OUTPUT 3
// update interval, make sure to keep it above 20ms
#define ULTRASONIC_TIMER_US 50000
@wolph
wolph / update_wan_ip.rsc
Created March 25, 2017 16:37
Mikrotik script to detect WAN IP updates and call scripts if it changes.
:global wanInterface "wan1"
:global wanIP "$wanIP"
# Get the current IP on the interface
:local currentIPtemp [/ip address get [find interface="$wanInterface" disabled=no] address];
# IP without netmask
:local currentIP [:pick $currentIPtemp 0 ([:len $currentIPtemp]-3)];
:if ($currentIP != $wanIP) do={