-
How can I pull daily stats from an API? I want to get current day home usage, solar generated, to Powerwall, from Powerwall, to grid and from grid kWh data. It is shown on the grafana dashboard but I cannot figure out if/how I can pull it from API. Is it possible? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
Hi David, yes you can pull this data directly from InfluxDB. Here is a curl statement that pulls the last 7 days of HOME usage (change # Use the kWh series - this uses the CQ data so will lag a bit between CQ runs but will be fast
curl 'http://localhost:8086/query?pretty=true' \
--data-urlencode "db=powerwall" \
--data-urlencode "q=SELECT sum(\"home\") FROM \"kwh\".\"http\" WHERE (\"home\" > 0) AND time >= now()-7d GROUP BY time(1d) fill(0) tz('America/Los_Angeles')"
# Use the autogen series - this uses raw data so will be most current
curl 'http://localhost:8086/query?pretty=true' \
--data-urlencode "db=powerwall" \
--data-urlencode "q=SELECT integral(\"home\") / 1000 / 3600 FROM \"autogen\".\"http\" WHERE time >= now()-7d GROUP BY time(1d) fill(0) tz('America/Los_Angeles')" Here is a simple script to pull all of the kwh meter data you are looking for: #!/bin/bash
# Pull meter data from InfluxDB
function fetch {
RESULT=""
RESULT=`curl --silent 'http://localhost:8086/query?pretty=true' \
--data-urlencode "db=powerwall" \
--data-urlencode "q=SELECT integral(\"${1}\") / 1000 / 3600 FROM \"autogen\".\"http\" WHERE time >= now()-7d GROUP BY time(1d) fill(0) tz('America/Los_Angeles')" | \
jq .results[].series[].values[7][1]`
}
for i in "home" "solar" "to_pw" "from_pw" "to_grid" "from_grid"
do
fetch "$i"
echo "$i: $RESULT"
done Example run:
|
Beta Was this translation helpful? Give feedback.
-
Excellent thank you. I'm really liking your powerwall-dashboard. I am integrating some data with a webpage I have that shows my security cameras... underneath the view of my front house I have some available space into which I already have managed to get the powerwall animated current flow graphic from pyPowerwall to display. Really cool. btw... that graphic can take up to 10 seconds to load. I there a known bottleneck somewhere? I assume you have to get it realtime from the Powerwall. |
Beta Was this translation helpful? Give feedback.
-
@jasonacox Is there a discussion/issue thread where the problem with the animation and firmware upgrade is discussed? I'd like to catch up on what is known about this before thinking too much about how I might improve things. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Lets move this over to here... jasonacox/pypowerwall#31 |
Beta Was this translation helpful? Give feedback.
Hi David, yes you can pull this data directly from InfluxDB. Here is a curl statement that pulls the last 7 days of HOME usage (change
localhost
to the host running the dashboard). The first uses the simple kwh data where the second computes the kwh data from raw (more current and is what the "meters" use on the Dashboard):