What is the best way to get historical data? #112
Replies: 5 comments
-
|
To me as well I am using the command The dash board of the inverter plant has a chart information with all days filled. The python response is always as line below: |
Beta Was this translation helpful? Give feedback.
-
|
👋 also thinking on how to export data from the servers to my local SQL for long term storage + data manipulation Using Result: The granularity seems to be lacking though, I have the collector set in the default 5min interval (didn't find a simple way to change the collection cycle to 1min) so would be nice to be able to get the whole set for a day. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @jbrinchmann, If you still didn't solve this, I suggest you to use the "mix_detail" function. It will return a json object with the correct chart data with a 5 min interval. The function you want to you is this one: mix_detail_json = api.mix_detail(device_sn, plant_id, growattServer.Timespan.hour, date)the chart data is accessible with the key "chartData": Below you can find a quick wrapper function I made to create a pandas dataframe with the chart data and their conversion to their KW consumption per each 5-minute data point, I hope it can be useful for you and other users: import pandas as pd
def retrieve_energy_data(date, device_sn, plant_id):
# collecting the chart data for a specific date
mix_detail_json = api.mix_detail(device_sn, plant_id, growattServer.Timespan.hour, date)
# preparing the dictionary to create the pandas dataframe
daily_inverter_dict = {}
daily_inverter_dict['time'] = []
daily_inverter_dict['ppv'] = []
daily_inverter_dict['sysOut'] = []
daily_inverter_dict['pacToGrid'] = []
daily_inverter_dict['pdischarge'] = []
daily_inverter_dict['pacToUser'] = []
for k, v in mix_detail_json['chartData'].items():
# storing the time values
daily_inverter_dict['time'].append(str(date) + ' ' + k)
# storing in the dictionary the plant production/consumption values
[daily_inverter_dict[key].append(value) for key, value in v.items()]
# creating the pandas dataframe
daily_df = pd.DataFrame.from_dict(daily_inverter_dict)
# reordering by datetime column
daily_df.time = pd.to_datetime(daily_df.time)
daily_df = daily_df.sort_values('time')
# rename columns to more understandable names
daily_df.rename(columns={'pacToGrid': 'exported_to_grid',
'ppv': 'solar',
'sysOut': 'load_consumption',
'pdischarge': 'from_battery',
'pacToUser': 'imported_from_grid'}, inplace=True)
# computing the real kW consumption per 5-minute interval
# main hypothesis is that the kWh is constant in the 5-minute intervals
for col in daily_df.drop(columns='time').columns:
# converting the values to float
daily_df[col] = daily_df[col].astype(float)
# converting the kWh to the 5-min interval
daily_df[col + '_minutes'] = daily_df[col] * (5/60)
# computing the self consumption values
daily_df['self_consumption_minutes'] = daily_df['load_consumption_minutes'] - daily_df['imported_from_grid_minutes']
return daily_df |
Beta Was this translation helpful? Give feedback.
-
|
Hi guys, I'm trying to get the historical data of my Growatt 600 TL-X. and so on...
I would like to get the api.tlx_detail(tlx_id) but for historic dates. |
Beta Was this translation helpful? Give feedback.
-
This doesn't seem to be working for me. Is anyone else having problems to access the mix_detail? I am unable to retrieve the historic data out of the API. Could anyone point me into the right direction, please? Thanks. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Hi, thanks very much for a very useful package!
I was wondering what the best way is to get historical data - I would like to get consumption over the last 24 hours, say, at e.g. 30 min result. I have a simple system with a single inversor and no batteries (for now). I had thought that perhaps I could use something like
dashboard_data = api.dashboard_data(<ID>, timespan=growattServer.Timespan['day'])but for me at least this gives a
chartDatawith no useful information.Beta Was this translation helpful? Give feedback.
All reactions