Skip to content

Commit 98f921c

Browse files
committed
Add SOC prediction log to markdown table converter
1 parent 54d4f52 commit 98f921c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

soc_log_table.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
# Convert SOC prediction log lines to a markdown table.
3+
# Usage: ./soc_log_table.sh /tmp/hass.log
4+
5+
grep 'SOC: Predicted' "${1:?usage: $0 <logfile>}" |
6+
sed 's/.*\([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\)\.[0-9]* .* Predicted \([0-9.]*%\).*(anchor=\([0-9.]*%\), +\([0-9.]* kWh\) net, eff=\([0-9]*%\)).*/\1|\2|\3|\4|\5/' |
7+
sort -t'|' -k1,1 -u |
8+
awk -F'|' 'BEGIN {
9+
print "| Time | Predicted | Anchor | Net energy | Efficiency |"
10+
print "|------|-----------|--------|------------|------------|"
11+
}
12+
{ printf "| %s | %s | %s | +%s | %s |\n", $1, $2, $3, $4, $5 }'

0 commit comments

Comments
 (0)