Skip to content

Instantly share code, notes, and snippets.

View ptagell's full-sized avatar

Paul Tagell ptagell

View GitHub Profile
@ptagell
ptagell / ha-solar-ev-referee-prompt.md
Created August 29, 2026 08:28
Prompt for an AI coding agent: build a solar-surplus EV charging referee in Home Assistant (true surplus, taper/pause/resume guard, battery floors, TOU schedule, size-the-overnight-charge). From https://tagell.com/who-gets-the-sunshine/

Prompt: build a "solar referee" for EV charging in Home Assistant

Paste this into an AI coding agent (Claude Code, Cursor, Codex, etc.) that has access to your Home Assistant config. It describes the system from Who gets the sunshine — a Home Assistant "referee" that decides, every minute, whether the sun should go to the car, the house battery or nobody, and that only buys grid power on purpose.

Everything in [brackets] is something the agent must ask you for or discover. Numbers in italics are the values that worked for one house in Central Victoria on a free‑11am–2pm solar‑soak tariff; keep them as defaults but expose every one as an input_number so they can be tuned without editing YAML.


The prompt

@ptagell
ptagell / fronius-phases.py
Created August 29, 2026 08:28
fronius-phases.py — live per-phase breaker-load monitor for a Fronius Smart Meter (terminal chart, circuit finder, CSV). From https://tagell.com/who-gets-the-sunshine/
#!/usr/bin/env python3
"""Fronius per-phase live monitor with breaker-load / trip-risk view.
Watch each phase at the grid smart meter, live: real power (kW), measured
current (A), and load as a percentage of the 50 A Type-C main. Colour-coded by
trip risk, and it times how long a phase has been over its rating (Type C trips
on *sustained* overload, not instantly).
Above the live table is a braille history chart of all three phases since the
run started — you can scroll back through it to review what happened.
@ptagell
ptagell / makeitrain.rb
Created August 26, 2020 22:35
Make it Rain Raspberry Pi GPIO controlling script
require 'httparty'
require 'json'
require 'dotenv/load'
url = 'https://websiteURLgoesHere'
if ENV['RaspberryPi'] == true
require 'rpi_gpio'
end
@ptagell
ptagell / Solar.rb
Created October 6, 2018 11:50
Selenium script to retrieve data from Fronius Solar Web and United Energy distributor.
require 'selenium-webdriver'
require 'dotenv/load'
require 'mailgun-ruby'
require 'open-uri'
require 'date'
require 'time'
require 'nokogiri'
require 'json'
require 'csv'
@ptagell
ptagell / behindTheMeter.rb
Last active September 26, 2018 22:01
Calculating Behind the Meter Solar Usage
require 'selenium-webdriver'
require 'dotenv/load'
require 'csv'
@headless = Selenium::WebDriver.for :firefox
def powershopLogin
@headless.navigate.to 'https://secure.powershop.com.au/'
username = @headless.find_element(:id, "email")
irb(main):129:0> value_to_evaluate
=> "\u00001\u00004\u00009\u00003\u0000"
irb(main):130:0> puts value_to_evaluate
1493
=> nil
irb(main):131:0> value_to_evaluate == 1493
=> false
irb(main):132:0>
@ptagell
ptagell / imageresize.rake
Created December 2, 2012 05:18
rake task
Link.all.each do |ym|
begin
ym.image.cache_stored_file!
ym.image.retrieve_from_cache!(ym.image.cache_name)
ym.image.recreate_versions!
ym.save!
end
end
@ptagell
ptagell / index.html.erb
Created May 26, 2012 23:52
List of goals
<% @goals.each do |goal| %>
<% if goal.committments.count == 1 && goal.committments.first.private_goal == true %>
<% else %>
<li>
<% if goal.committments.count > 1 %>
<p><small><%= goal.committments.count %> people want to</small></p>
<% else %>
<p><small><%= goal.committments.count %> person wants to</small></p>
<% end %>
@ptagell
ptagell / babies_controller.rb
Created December 22, 2011 23:02
Working code for update
def update
# @baby = Baby.find(params[:id])
if @baby.update_attributes(params[:baby])
if @baby.previous_changes[:notify]
redirect_to root_url, notice: "Done"
else
redirect_to(root_url(:host => with_subdomain(@baby.subdomain)), :notice => 'Your baby was successfully updated and everyone has been told the good news.')
end
else
@ptagell
ptagell / Babies_controller.rb
Created December 22, 2011 22:41
Update using dirty
def update
if @baby.update_attributes(params[:baby])
if baby.notify.changed?
flash[:notice] = "Done"
else
redirect_to(root_url(:host => with_subdomain(@baby.subdomain)), :notice => 'Your baby was successfully updated and everyone has been told the good news.')
end
else
render :action => "edit"
end