Skip to content

Instantly share code, notes, and snippets.

@OPVL
OPVL / quantity_unit.py
Created July 13, 2024 15:29
Script to import quantity units & associated conversion factors in to grocy, pythonically
### This script adds metric (UK) units and unit conversions to grocy
### inspired by https://gist.github.com/randompherret/f772d43cb618b55997f203e023631d5f
### this script is by no means perfect however it can handle failed runs and restarting midway through
### usage: python quantity_units.py
### make sure to set the environment variables in a .env file in the same directory as this script
### GROCY_API_KEY and GROCY_BASE_URL are required
### LOG_TO_FILE and DELETE_EXISTING_UNITS are optional
### LOG_TO_FILE will log the added units and conversions to a file (not used for anythning just interesting)
### DELETE_EXISTING_UNITS will delete all existing units in grocy before adding new ones