Skip to content

Instantly share code, notes, and snippets.

View WouterGritter's full-sized avatar

Wouter Gritter WouterGritter

View GitHub Profile
@WouterGritter
WouterGritter / mqtt.py
Last active January 26, 2025 16:01
WeeWX MQTT driver
"""
A custom weewx driver to support collecting data from a MQTT broker.
In combination with https://github.com/WouterGritter/433-mqtt-bridge, this driver can be used to
collect information from any 433, 868 or 915 MHz weather station using a Software Defined Radio dongle.
Using a MQTT broker as a go-between, the same raw data can be used in other places, for example in
Home Assistant or in Grafana.
This driver expects the units to be in a specific metric format. See conversion in the source-code
below (around line 70), and feel free to modify the multiplier values.
@WouterGritter
WouterGritter / regexMap.ts
Created May 31, 2024 12:43
TypeScript RegexMap implementation (use regexes within the get/has/delete methods)
export class RegexMap<T> implements Map<string, T> {
private readonly backend: Map<string, T>;
constructor(entries?: readonly (readonly [string, T])[] | null) {
this.backend = new Map<string, T>(entries);
}
toJSON(): { [key: string]: T; } {
const result: { [key: string]: T; } = {};