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
Reconciling API data with Fox Cloud 2.0 app
-
- Posts: 1293
- Joined: Thu Oct 13, 2022 7:21 pm
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
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
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
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
And looking at those generation numbers a little more, they don't look right as there's no way I would be generating anything in the middle of the night. The early hours are too high and the peak sun hours are too low.
One other update - the Fox ESS web site agrees with the API in terms of the "today" yield. The app shows something completely different. However, the web site has an icon that implies "the last 24 hours", whereas the API documentation says it's for today in the timezone of the power station.
Chris
One other update - the Fox ESS web site agrees with the API in terms of the "today" yield. The app shows something completely different. However, the web site has an icon that implies "the last 24 hours", whereas the API documentation says it's for today in the timezone of the power station.
Chris
-
- Posts: 1293
- Joined: Thu Oct 13, 2022 7:21 pm
Hi Chris,
The production figure shown in the app (V2) is actually solar generated, whereas the generation figure you are looking at from the OpenAPI is yield - for a solar only inverter these are essentially the same thing but for a hybrid inverter this is all of the work the inverter does whether it's from solar or battery - that's why you are 'generating' during the night.
The app has access to the solar generated total (sadly we don't through the api) - have a read of this thread written some time ago which explains what the cloud data is actually providing. https://github.com/macxq/foxess-ha/wiki ... -foxess-ha
To be honest I don't look much at the cloud data anymore as I have home assistant (connected over modbus) and that gives you access to high resolution data and most of the inverters stats registers (as well as allowing local control) i've linked you to a wiki page that explains that if you are interested in connecting your inverter https://github.com/nathanmarlor/foxess_ ... ring-Guide
The production figure shown in the app (V2) is actually solar generated, whereas the generation figure you are looking at from the OpenAPI is yield - for a solar only inverter these are essentially the same thing but for a hybrid inverter this is all of the work the inverter does whether it's from solar or battery - that's why you are 'generating' during the night.
The app has access to the solar generated total (sadly we don't through the api) - have a read of this thread written some time ago which explains what the cloud data is actually providing. https://github.com/macxq/foxess-ha/wiki ... -foxess-ha
To be honest I don't look much at the cloud data anymore as I have home assistant (connected over modbus) and that gives you access to high resolution data and most of the inverters stats registers (as well as allowing local control) i've linked you to a wiki page that explains that if you are interested in connecting your inverter https://github.com/nathanmarlor/foxess_ ... ring-Guide
-
- Posts: 14
- Joined: Sun Mar 19, 2023 4:37 pm
There's a lot of stuff wrong with the Open API data from the point of view of PV generation and you can't get the Production data as shown in the Fox Apps. As it happens, the Fox Production data is wrong as well when you are looking at the Day figures. You have to look at the Month figures by Day to get the correct totals. I can explain why this is, if you are interested...
You might want to have a look at the information here: https://github.com/TonyM1958/FoxESS-Cloud. This is a python module that does the heavy lifting of using the Fox API / Open API and makes it relatively easy to get correct data.
Have a look at the wiki and some of the scripts linked in there. For example: https://github.com/TonyM1958/FoxESS-Clo ... production will pull your PV production data for a day and show you the totals for each string.
You might want to have a look at the information here: https://github.com/TonyM1958/FoxESS-Cloud. This is a python module that does the heavy lifting of using the Fox API / Open API and makes it relatively easy to get correct data.
Have a look at the wiki and some of the scripts linked in there. For example: https://github.com/TonyM1958/FoxESS-Clo ... production will pull your PV production data for a day and show you the totals for each string.
H1-6.0-E hybrid inverter
6 x HV2600 v2 batteries
16 x JA Solar 405w panels
7 x Tigo TS4-A-O optimisers
6 x HV2600 v2 batteries
16 x JA Solar 405w panels
7 x Tigo TS4-A-O optimisers
Thank you tony.matthews for the useful github links..tony.matthews1 wrote: ↑Mon Sep 23, 2024 5:02 pm There's a lot of stuff wrong with the Open API data from the point of view of PV generation and you can't get the Production data as shown in the Fox Apps. As it happens, the Fox Production data is wrong as well when you are looking at the Day figures. You have to look at the Month figures by Day to get the correct totals. I can explain why this is, if you are interested...
You might want to have a look at the information here: https://github.com/TonyM1958/FoxESS-Cloud. This is a python module that does the heavy lifting of using the Fox API / Open API and makes it relatively easy to get correct data.
Have a look at the wiki and some of the scripts linked in there. For example: https://github.com/TonyM1958/FoxESS-Clo ... production will pull your PV production data for a day and show you the totals for each string.