Last active
April 27, 2022 06:22
-
-
Save tserong/6e4167c3b02387acc199a158cc95fafe to your computer and use it in GitHub Desktop.
Log ZCell state of charge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Polls the ZCell BMS REST API once per minute and prints the | |
# current state of charge. Runs indefinitely. | |
# Requires `curl` and `jq`. | |
# | |
# Note: this only looks at the first battery in the system | |
# (".list[0]" in the `jq` invocation). | |
# | |
if [ -z "$1" ]; then | |
echo "Usage: $(basename $0) BMS_IP [POLL_INTERVAL]" | |
exit 1 | |
fi | |
STATUS_URL="http://${1}:3000/rest/1.0/status" | |
INTERVAL="${2:-60}" | |
LAST="" | |
echo "Polling ${STATUS_URL} at ${INTERVAL} second intervals" | |
while true ; do | |
curl -s ${STATUS_URL} | jq -r '.list[0].state_of_charge' | |
sleep $INTERVAL | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment