Skip to content

Instantly share code, notes, and snippets.

"""
Takes in a set of files calculates the value sum from time periods designated in a YAML file
Install library requirements first (pandas generally installed via OS, on Linux sudo apt install python3-pandas)
"""
import argparse
import datetime
import os
import os.path
import pandas
import sys
@robweber
robweber / update_godaddy_dns.py
Last active January 13, 2024 13:21
Use the GoDaddy API to update a DNS record when external IP changes
"""update_godaddy_dns.py
Updates a GoDaddy DNS record with a new external IP address using the GoDaddy API
Run in debug mode (-D) to check the IP but not update DNS records
https://developer.godaddy.com/doc/endpoint/domains
Requires:
configargparse
requests
"""
@robweber
robweber / low_battery_blueprint.yaml
Last active November 6, 2022 16:28
Home Assistant Blueprints
blueprint:
name: Low battery level detection & notification for all battery sensors
description: Regularly test all sensors with 'battery' device-class for crossing
a certain battery level threshold and if so execute an action. Marck/home-assistant-automation-blueprints/blob/main/low-battery-level-detection-notification-for-all-battery-sensors
domain: automation
input:
threshold:
name: Battery warning level threshold
description: Battery sensors below threshold are assumed to be low-battery (as
well as binary battery sensors with value 'on').
@robweber
robweber / backup.py
Last active July 1, 2022 19:42
Command Line Backups Solution
"""Backup utility
Performs a backup of files and directories given in a YAML configuration file. This is done by first putting them all in a tar archive
and then using the smbclient package to copy the file to the destination.
Run with: python3 backup.py -c /path/to/config.yaml
requires jinja2 and pyyaml """
import argparse
import os
@robweber
robweber / filter_color.py
Last active February 28, 2022 17:52
Filter an Image based on an array of colors
import argparse
import os.path
from PIL import Image
def create_palette(colors):
result = []
for c in colors:
rgb_values = c.split(',')
# there must be 3
@robweber
robweber / calc_energy.py
Created February 28, 2022 16:42
Calculate energy based on load percent
"""calc_energy.py
calculate the energy usage based on a load percentage and max power rating
"""
def calc_energy(current_load, max_load, min=5, unit='W'):
# load percent * max load
current_power = (current_load/100) * max_load
# multiply the power by the time increment
# time increment should be in hours
@robweber
robweber / pullrequest.sh
Last active August 22, 2019 22:48
Kodi Addon Checker Pull Request Script
#!/bin/bash
#will either check your addon (same as PR will do) or send a pull request on up to the repo
#cultivated from instructions at https://kodi.wiki/view/HOW-TO:Create_add-on_PRs_using_Git_Subtree_Merging and modified
## ARGS pass in file to source other args as -f or --filename ##
ADDON_CHECKER_VERSION=0.0.14
KODI_FORK=https://github.com/robweber/repo-scripts.git
KODI_REPO_BRANCH=jarvis
ADDON_URL=https://github.com/robweber/xbmcbackup.git
ADDON_BRANCH=master