Skip to content

Instantly share code, notes, and snippets.

@tserong
tserong / rc.local
Created July 1, 2022 04:10
/data/rc.local script for Victron Cerbo GX to install custom crontab entry to run /home/root/sched.py
#!/bin/sh
if ! grep -q 'sched\.py' /etc/crontab; then
mount | grep -q 'on / .*ro'
is_ro=$?
if [ $is_ro -eq 0 ]; then
mount -o remount,rw /
fi
cat >> /etc/crontab <<EOF
# Set scheduled charges based on zcell maintenance cycle
#!/bin/bash
HOME=${HOME:-/tmp}
WARNING_URL=ftp://ftp.bom.gov.au/anon/gen/fwo/IDT29000.txt
LAST_WARNING=$HOME/sheep-graziers-warning.last
NEXT_WARNING=$HOME/sheep-graziers-warning.next
rm -f $NEXT_WARNING
/usr/bin/curl -s -o $NEXT_WARNING $WARNING_URL
[ -e "$NEXT_WARNING" ] || exit 0
@tserong
tserong / set-minsoc.py
Created November 9, 2023 08:07
Set the minum state of charge to the specified value, or zero if it's a maintenance day and the --check-maintenance paramenter is set.
#!/usr/bin/env python3
import argparse
import dbus
import logging
import requests
from datetime import datetime
# Note that when log output lands in /var/log/messages via cron, lines are
# truncated at about 250 characters for some reason.