Skip to content

Instantly share code, notes, and snippets.

@mharizanov
mharizanov / README.md
Created September 12, 2026 06:40
Pool filter + solar heater pumps scheduled by the PV forecast in Home Assistant: tiered filter target, solar bursts, manual backoff, load anomaly guard (companion to the harizanov.com pool post)

Pool pumps on the PV forecast — Home Assistant package

Companion to the harizanov.com post Home Assistant took the pool off the timer. Two smart-plugged pumps — a sand filter and a solar circulator feeding 200 m of black pipe on a roof — scheduled by the day's PV forecast and the live PV output instead of a clock, with a manual override that backs the automation off and a load guard that stops a pump running dry.

What it does

  • Filter, daily target by tier. The PV forecast (sensor.energy_production_today, Forecast.Solar) picks MIN / STD / HIGH hours; the tier is promoted by PV actually delivered today or by a 30-minute PV average, because
@mharizanov
mharizanov / README.md
Created September 12, 2026 06:20
SONOFF SWV zone irrigation from Home Assistant with the timer on the valve (cyclic_timed_irrigation via Zigbee2MQTT) — companion to the harizanov.com irrigation post

SONOFF SWV zone irrigation from Home Assistant, with the timer on the valve

Companion to the harizanov.com post on garden irrigation. Anonymized: replace the Zigbee2MQTT device names and the helper names with yours.

The problem this solves

The obvious way to run a valve for N minutes is switch.turn_on → delay → switch.turn_off. It works until Home Assistant restarts, or you reload scripts/automations from the UI, in the middle of a run. The delay dies with the script and the valve stays open. With six zones and a

@mharizanov
mharizanov / README.md
Last active August 30, 2026 13:29
Home Assistant storm cell / hail alerts: RainViewer radar decoding + Blitzortung + MeteoAlarm (harizanov.com)

Storm cell / hail alerts for Home Assistant (RainViewer radar + Blitzortung + MeteoAlarm)

Companion code for the blog post: Storm cell and hail alerts in Home Assistant from RainViewer radar https://harizanov.com/?p=8869

Three layers of lead time, plus the same thing for a car tracked via TeslaMate.

Files

| File | What it is |

@mharizanov
mharizanov / fit_clearsky.py
Created July 28, 2026 14:02
Fit a clear-sky 'ideal produce' PV curve from Home Assistant recorder history and emit a template sensor (companion to the harizanov.com clear-sky line post)
#!/usr/bin/env python3
"""Fit a clear-sky ("ideal produce") PV curve to your own Home Assistant history.
The idea: clouds only ever subtract. Bin a few years of hourly PV output by sun
position and the top ~2-4% of every bin is what your array does under a clear sky.
Fit a small physical model to that envelope and you get an "ideal produce" curve
you can overlay on actual production - no panel datasheet or roof measuring needed.
At the end this script prints a ready-to-paste Home Assistant template sensor.
Companion post: https://harizanov.com/ (search "clear-sky line")
@mharizanov
mharizanov / thematrix.ino
Last active November 12, 2018 12:59
the matrix ili9431
// A fun MATRIX-like screen demo of scrolling
// Screen will flicker initially until fully drawn
// then scroll smoothly
#define ILI9341_VSCRDEF 0x33
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include <SPI.h>
SPIClass SPI2(HSPI);
@mharizanov
mharizanov / gist:e8c01130c72909393b50
Created September 2, 2014 13:28
Solar water tank node with DQ checks
[{"id":"ba386057.845d3","type":"mqtt-broker","broker":"localhost","port":"1883"},{"id":"650ec6ce.937bc","type":"mqtt in","name":"Solar water tank raw","topic":"home/solar/raw","broker":"ba386057.845d3","x":94,"y":1469,"z":"31c82d7c.ce37d2","wires":[["1a8bcb53.521cf5"]]},{"id":"f6db14b.48de768","type":"trigger","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"15","extend":"true","units":"min","name":"Heratbeat monitor","x":476,"y":1400,"z":"31c82d7c.ce37d2","wires":[["fc298d6a.cf894"]]},{"id":"650a1683.332eb8","type":"inject","name":"Initial heartbeat","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"","once":true,"x":103,"y":1400,"z":"31c82d7c.ce37d2","wires":[["f6db14b.48de768"]]},{"id":"a0c7803f.d6f2a","type":"function","name":"Parse solar node payload","func":"// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n// console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n/
@mharizanov
mharizanov / Wallpaper_prank
Last active December 15, 2015 22:09
Description: Minimizes all windows to desktop, takes screenshot, disables desktop icons, saves screenshot in %userprofile% and sets as wallpaper
//Description: Minimizes all windows to desktop, takes screenshot, disables desktop icons, saves screenshot in %userprofile% and sets as wallpaper
void setup(){
delay(10000);
Keyboard.begin();
//Show desktop
Keyboard.press(KEY_LEFT_GUI);
Keyboard.write('d');
@mharizanov
mharizanov / WiFiCheck
Created April 6, 2013 08:50
Script to check and re-connect WiFi on Raspberry Pi
#!/bin/bash
##################################################################
# A Project of TNET Services, Inc
#
# Title: WiFi_Check
# Author: Kevin Reed (Dweeber)
# dweeber.dweebs@gmail.com
# Project: Raspberry Pi Stuff
#
# Copyright: Copyright (c) 2012 Kevin Reed <kreed@tnet.com>