Reconciling API data with Fox Cloud 2.0 app
Posted: Sat Sep 21, 2024 4:01 pm
by cpwood
Hi all,
I've recently had my solar panels, inverter (H1) and battery installed and, since I'm a geek, I'm playing around with the OpenAPI at the moment.
I'm using the /op/v0/device/history/query endpoint to pull back historic data of a number of different types (i.e. variables), but to confirm I'm not doing anything daft in my code, I'm trying to reconcile the numbers I'm getting back from the API with what I see in the Fox Cloud 2.0 app. However, they're not reconciling and I'm wondering if there's something daft that I'm missing.
To keep it as simple as possible, I've tried pulling back the "generation" variable ("Cumulative power generation" measured in kWh), and I would expect the difference in the end-of-day value and start-of-day value to be equal to the "production" total value shown in the app, but it's not. I'm in the UK, so have also checked it's not a UTC vs BST issue too, and it's not.
To give a real example, for the 20th, the app says 10.9 kWh of electricity was produced. The difference between start and end of day cumulative generation variable according to the API data is 9.0 kWh, either on a UTC basis or a BST basis.
Is there something I'm not taking into account here?
Appreciate any pointers!
Chris
Re: Reconciling API data with Fox Cloud 2.0 app
Posted: Sun Sep 22, 2024 9:23 am
by Dave Foster
That's not the best way to get your totals, one of the problems with this is that the cumulative 'total' generation is built from the generation total which is an hour based variable and so you get problems at the start and end of the day as the totals haven't yet been updated for the last/previous hour from the real time data samples (every 5 minutes).
The better way to get the total data is to use the production report, this will return generation, feedin, gridConsumption, chargetotal and dischargetotal as totals by 'full' day from the statistics total register i.e.
{"sn":"60BHxxxxxxxxxxx","year":2024,"month":9,"dimension":"month","variables":
["feedin","generation","gridConsumption","chargeEnergyToTal","dischargeEnergyToTal","loads"]}
Would return
[{'unit': 'kWh', 'values': [3.400000000000091, 3.0, 15.599999999999909, 12.800000000000182, 2.0, 16.40000000000009, 3.599999999999909, 0.1999999999998181, 8.5, 7.700000000000273, 9.699999999999818, 10.699999999999818, 11.800000000000182, 11.5, 2.0, 13.0, 15.300000000000182, 13.0, 12.799999999999727, 7.599999999999909, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'variable': 'feedin'}, {'unit': 'kWh', 'values': [16.900000000001455, 15.199999999998909, 28.700000000000728, 25.899999999999636, 14.5, 29.799999999999272, 13.400000000001455, 15.799999999999272, 21.100000000000364, 20.600000000000364, 21.69999999999891, 22.700000000000728, 19.600000000000364, 22.600000000000364, 8.600000000000364, 24.600000000000364, 29.299999999999272, 26.80000000000109, 25.099999999998545, 14.200000000000728, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'variable': 'generation'}, {'unit': 'kWh', 'values': [20.100000000000364, 16.900000000001455, 18.0, 16.700000000000728, 15.5, 17.30000000000109, 15.5, 13.699999999998909, 20.100000000000364, 20.30000000000109, 15.5, 12.399999999999636, 13.399999999999636, 10.100000000000364, 10.899999999999636, 8.199999999998909, 17.30000000000109, 17.399999999999636, 15.399999999999636, 13.600000000000364, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'variable': 'gridConsumption'}, {'unit': 'kWh', 'values': [17.099999999999454, 11.5, 10.699999999999818, 9.600000000000364, 9.0, 10.0, 9.0, 8.300000000000182, 14.199999999999818, 11.199999999999818, 10.600000000000364, 8.299999999999272, 7.100000000000364, 7.800000000000182, 9.099999999999454, 6.300000000000182, 9.199999999999818, 10.0, 8.699999999999818, 6.100000000000364, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'variable': 'chargeEnergyToTal'}, {'unit': 'kWh', 'values': [7.399999999999636, 6.900000000000546, 5.800000000000182, 4.799999999999272, 6.100000000000364, 5.0, 3.899999999999636, 12.0, 5.5, 6.200000000000728, 3.899999999999636, 5.100000000000364, 2.0, 4.600000000000364, 2.0, 4.899999999999636, 6.100000000000364, 6.300000000000182, 6.699999999999818, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'variable': 'dischargeEnergyToTal'}, {'unit': 'kWh', 'values': [16.799999999999272, 18.0, 20.799999999999272, 20.5, 19.399999999999636, 21.100000000000364, 16.899999999999636, 21.5, 18.700000000000728, 24.299999999999272, 17.5, 16.700000000000728, 14.399999999999636, 16.799999999999272, 8.899999999999636, 13.900000000001455, 22.400000000001455, 20.69999999999891, 18.600000000000364, 13.799999999999272, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'variable': 'loads'}]
Where the index is the day so for the 6th of the month feedin = 16.4kWh, generation = 29.8kWh, gridconsumption = 17.3kwh etc..
Or if you are only looking for that generation total you see in the variables data (actually 'total yield') the best report to get that is the power generation report
path = /op/v0/device/generation
request:{"sn":"60BHxxxxxxxxxxx","dimension":"day"}
would return -
{"month":417.2000000000007,"today":14.200000000000728,"cumulative":10185.5}}
i.e. Generation Report data: todays value 14.200000000000728, month value 417.2000000000007, cumulative value 10185.5
Re: Reconciling API data with Fox Cloud 2.0 app
Posted: Sun Sep 22, 2024 2:04 pm
by cpwood
Thanks for the pointers, Dave - much appreciated.
I did discover the production end point and have been playing around with it using hourly data. I'm pulling back the following variables:
"generation", "feedin", "gridConsumption", "dischargeEnergyToTal", "loads"
For the 20th, my Fox Cloud app shows:
Production: 10.9 kWh
Export: 0.8 kWh
Consumption: 8.5 kWh
Grid Purchase: 1.2 kWh
Pulling back data from the production endpoint for that same date, I get the following totals:
Production (generation): 8.3 kWh (2.6 kWh lower than what the app shows)
Export (feedin): 0.8 kWh
Consumption (loads): 8.5 kWh
Grid Purchase (gridConsumption): 1.2 kWh
So again, the generation total differs in the app to the API. The discrete values pulled back were:
{
"unit": "kWh",
"values": [
0.20000000000000284,
0.29999999999999716,
0.20000000000000284,
0.20000000000000284,
0.29999999999999716,
0.29999999999999716,
0.3999999999999915,
0.30000000000001137,
0.19999999999998863,
0.4000000000000057,
0.30000000000001137,
0.19999999999998863,
0.20000000000000284,
0.3999999999999915,
0.4000000000000057,
0.8999999999999915,
0.4000000000000057,
0.4000000000000057,
0.29999999999999716,
0.5,
0.5,
0.3999999999999915,
0.29999999999999716,
0.29999999999999716
],
"variable": "generation"
},
It feels like the "production" value in the app might be the sum of something rather than just the total of the "loads" data alone. Do you have any thoughts on what that might be?
I've just tried the /op/v0/device/generation endpoint (which won't quite do what I want as I'm wanting a previous day's value), however even that's inconsistent. It's claiming 8.5 kWh for today's value and the app says 3.5 kWh (with the latter seeming more reasonable given the horrid weather!).
Agree on your points on the history endpoint, though having said that, it was a good 12-and-a-bit hours after the start of the 20th before I tried pulling any data back.
Really appreciate the time you've taken to help!
All the best,
Chris