#!/bin/sh
# Gather detailed by-minute Eddi stats for the stated day.
# This will all be more sane if the eddi doesn't do DST, ie stays on UTC.
# Picks up credentials from ~/.netrc so may not be suitable for batch.

# Usage:
#     $0 yyyy-mm-dd

. script/myenergi/.config

#exec curl --silent --digest --netrc -H 'accept: application/json' -H 'content-type: application/json' --compressed "https://s18.myenergi.net/cgi-jday-E$eddisn-$1"
exec curl -u "$hubsn":"$APIkey" --silent --digest --netrc -H 'accept: application/json' -H 'content-type: application/json' --compressed "https://s18.myenergi.net/cgi-jday-E$eddisn-$1"

# In case of error output may look like:

% script/myenergi/eddiStatsByMin-netrc.sh 2023-12-33
{"status":"-14","statustext":""}

# Normal output may look like:
% script/myenergi/eddiStatsByMin-netrc.sh 2023-12-31
{"U14113347":[{"yr":2023,"mon":12,"dom":31,"dow":"Sun","imp":8120,"pect1":8178,"hsk":317,"v1":2459,"frq":5007},{"yr":2023,"mon":12,"dom":31,"dow":"Sun","min":1,"imp":7980,"pect1":8040,"hsk":315,"v1":2457,"frq":5006},{"yr":2023,"mon":12,"dom":31,"dow":"Sun","min":2,"imp":7980,"pect1":7980,"hsk":313,"v1":2452,"frq":5004},{"yr":2023,"mon":12,"dom":31,"dow":"Sun","min":3,"imp":7980,"pect1":7980,"hsk":312,"v1":2453,"frq":5004}, ... ,{"yr":2023,"mon":12,"dom":31,"dow":"Sun","hr":23,"min":58,"imp":4800,"pect1":4800,"hsk":259,"v1":2452,"frq":5012},{"yr":2023,"mon":12,"dom":31,"dow":"Sun","hr":23,"min":59,"imp":4980,"pect1":4980,"hsk":259,"v1":2454,"frq":5012}]}


##########
# May be used / adapted / etc without any promise of fitness for purpose
# under the terms of the Apache License Version 2.0, January 2004
#     http://www.apache.org/licenses/LICENSE-2.0
##########
