#!/bin/sh
# Extracts just timestamp and "Power" value from stdin
# and also corrects for the missing Z on the timestamp.
# Output should be suitable to feed to (eg) gnuplot.
# DHD20221010: allows for the power to have a fraction part.

# Sample input:
#2022-10-10T09:46:01Z {"StatusSNS":{"Time":"2022-10-10T10:46:02","ENERGY":{"TotalStartTime":"2022-10-05T19:17:26","Total":3.054,"Yesterday":1.230,"Today":0.027,"Power":102.0,"ApparentPower":102.0,"ReactivePower":0.0,"Factor":1.00,"Voltage":249,"Current":0.410}}}

# Sample output:
#2022-10-10T09:46:01Z 102.0

# Run something like:
#% cat LBplug-2022-10-10.log.gz | sh ./powerExtractZ.sh > input.dat

# Retain the timestamp (appending a 'Z'),
# and discard everything else other than the Power decimal.
exec sed -e 's/ {.*"Power": *\([0-9][0-9.]*\),.*$/ \1/'
