Skip to content

Instantly share code, notes, and snippets.

@ArrEssJay
ArrEssJay / slope.qml
Created October 7, 2019 03:36
QGIS Slope-Aspect Map (Slope)
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis styleCategories="AllStyleCategories" minScale="1e+08" hasScaleBasedVisibilityFlag="0" version="3.8.0-Zanzibar" maxScale="0">
<flags>
<Identifiable>1</Identifiable>
<Removable>1</Removable>
<Searchable>1</Searchable>
</flags>
<customproperties>
<property value="false" key="WMSBackgroundLayer"/>
<property value="false" key="WMSPublishDataSourceUrl"/>
@ArrEssJay
ArrEssJay / heaterScheduler.flux
Last active April 12, 2022 14:04
Flux (InfluxDB) Price Driven Heater Controller, using Amber (aus) price data and modbus power monitoring.
// Hybrid wholesale price (feed-forward) and proportional (feedback) storage water heater controller.
// Tries to keep the tank hot and the bill low
// This query runs every half hour (NEM metering period) and determines for the next 18 hours (available forecast period)
// how much time is needed to heat the water tank and which are the cheapest times to do that
// Basic theory
// Wholesale electricity prices are volatile. Lots of renewables means low prices. The storage heater allows us to ride out
// expensive periods by only heating water when it's cheap. This is fine until a week of rain means we run out of hot water.
@ArrEssJay
ArrEssJay / telegraf.conf
Created April 14, 2022 06:24
UBX GNSS data -> telegraf using pyubx2 outputting JSON
# The lambda function coerces pyubx2 into outputting JSON. Requires importing the `jsons` library
[[inputs.execd]]
command = ["gnssdump", \
"port=/dev/ttyACM0", \
"baudrate=921600",
"protfilter=2", \
"verbosity=0", \
"ubxhandler=lambda msg: print(jsons.dumps((lambda msg: {key:value for (key,value) in dict(msg.__dict__, **{'msg':msg.identity}).items() if not key.startswith('_') } )(msg)))", \
"msgfilter=NAV-PVT"]
@ArrEssJay
ArrEssJay / heating_state.py
Created June 29, 2022 14:03
HA PyScript Load Control
@state_trigger("sensor.scheduled_heating_state", state_check_now=True)
@service
def price_load_control():
"""Turn OFF or ON water heater by price signal (obey overrides)"""
if state.get("input_select.water_heating_mode") == "auto":
scheduled_state = sensor.scheduled_heating_state
log.warning(f"Load control state: {scheduled_state}")
if scheduled_state == '0':
switch.turn_off(entity_id = "switch.storage_heater")
log.warning(f"Load control triggered water heater OFF")
@ArrEssJay
ArrEssJay / gps.sh
Last active August 7, 2022 13:47
Parse gpsd JSON messges with telegraf
#!/bin/bash
gpspipe -w | jq -c -M '. | select( (.class == "SKY" and has("satellites") == true) or .class == "TPV")' | while IFS= read obj
do
echo $obj
done
@ArrEssJay
ArrEssJay / gist:2ca9f518b78716bd151bce62f02a74d5
Created July 28, 2023 00:17
Convert GQRX IQ Recording to SDRTrunk
// GQRX IQ recording:
// Raw interleaved IQ samples, 32-bit IEEE float @ receiver sampling rate
//
// SDRTrunk recording:
// WAV file, interleaved IQ samples, signed 16-bit @ receiver sampling rate
//
// 'sox' can be used to downsample and append the WAV header
sox -c 2 -t f32 -r 2400000 <infile> -b 16 -t wav <outfile>