Skip to content

Instantly share code, notes, and snippets.

View mairas's full-sized avatar

Matti Airas mairas

View GitHub Profile
@mairas
mairas / n2k_example.cpp
Created January 14, 2021 15:01
NMEA 2000 output from SensESP
// wire up a DS18B20 (OneWire device)
DallasTemperatureSensors* dts = new DallasTemperatureSensors(ONEWIRE_DQ_PIN);
uint onewire_read_delay = 500;
auto* onewire_temp =
new OneWireTemperature(dts, onewire_read_delay, "/temperature/oneWire");
onewire_temp->connect_to(
@mairas
mairas / iterm.py
Created March 14, 2022 11:34
Launch a new iTerm2 window from command line with optional custom path and command arguments
#!/usr/bin/env python3
import iterm2
import AppKit
import click
import os
@click.command()
@click.argument(
@mairas
mairas / parent_args.py
Created September 4, 2023 15:23
How to access parent field arguments in Strawberry GraphQL
# Let's say you have a user with id "XXX" and you want to get all the
# groups that user is a member of. The query below should do the trick.
#
# However, when implementing the query and the types with Strawberry,
# it becomes essential that the groups relay connection has access to the
# user id. This is a hassle in Strawberry because the information is only
# available in the abstract syntax tree that you have to traverse
# manually.
#
# The code in this gist shows how to do that. It's not pretty, but it works.
@mairas
mairas / configuration.yaml
Created November 20, 2023 21:11
HA Smart Thermostat setup for multiple TRVs
climate:
- platform: smart_thermostat
name: Olohuone Smart Thermostat
unique_id: olohuone_smart_thermostat
# target input_number has been created manually in Settings -> Devices & services -> Helpers
heater: input_number.olohuone_smart_thermostat_valve_state
target_sensor: sensor.olohuone_pvvx_temperature
min_temp: 10
max_temp: 24
ac_mode: False