home-assistant-zonneplan-one icon indicating copy to clipboard operation
home-assistant-zonneplan-one copied to clipboard

Use live data as last values

Open yurnih opened this issue 1 year ago • 8 comments

Currently, the PV entities are based on meta values. These values get updated only when getting data from the user accounts-endpoint. Since some versions it receives an update every hour. However, we are also polling live data every 5 minutes with newer "last values" but not using those. With this commit I use the latest values to update the meta data, so the entities gets updated in HA.

It works locally for me for my configuration (1 solar panel system). I do not think it will works with multiple, although I do not know how the Zonneplan gives us these data in such configurations.

yurnih avatar Dec 30 '23 15:12 yurnih

so since we are not updating the account info every hour anymore some sensor data isn't updated correctly anymore?

isn't it easier to change the origin of the sensor data instead of introducing this calculation? I'm even for updating the account data every 5 minutes again. Adding more complexity in converting the incoming data will only give trouble at a later point in time.

Guess this is for all meta fields used in https://github.com/fsaris/home-assistant-zonneplan-one/blob/main/custom_components/zonneplan_one/const.py

fsaris avatar Dec 31 '23 13:12 fsaris

The easiest way is to update the account data every 5 minutes again. Changing the const to use the last measurement from the live data is during the day okay, but it will need extra checks if the data is available (live data shows only measurements from the last 3 hours, at night and in morning the list is none). The total for the inverter is not available from the live data, this property only exists in the account info. To get an update for that property it requires some calculation when using only the live data.

I don't know if it gives issues with the zonneplan api (rate limit of 60 in headers), since if it is like app-style, requests get mainly send to the chart-endpoints as somehow mentioned in #89.

yurnih avatar Dec 31 '23 17:12 yurnih

I'm seeing similar issues where the solar power data is only fetched once an hour right now.

martijnrusschen avatar Jan 09 '24 08:01 martijnrusschen

I thought because of recent changes all is updated every hour, but I was wrong. Now the sun is shining I saw yield_today getting updates, but last_measured_value only once a month. So not really (just) a rate limit issue?

Ascathon avatar Jan 09 '24 12:01 Ascathon

The requests don't seem to be consistently every hour. Based on today's data here are some data points it pulled:

  • 9:11
  • 10:11
  • 11:11
  • 12:08

I enabled the debug logging to understand if it's hitting an error or rate limit, but I can't see anything weird. Once it's making the request it comes in fine, but it's not doing it every 5 minutes anymore. @fsaris would it make sense to revert to a previous version to test if it works fine in a previous iteration?

martijnrusschen avatar Jan 10 '24 11:01 martijnrusschen

I did a reboot at 12:08 which seems to indicate it may pull directly at a reboot. I will try to confirm that.

martijnrusschen avatar Jan 10 '24 11:01 martijnrusschen

Another reboot done at 12:26 and it pulled new data after the reboot. Expecting the next fetch will be at 13:26 now.

martijnrusschen avatar Jan 10 '24 11:01 martijnrusschen

@martijnrusschen the accounts endpoint is called once each hour. So if your install starts at 1:12 the next fetch wil be 2:12 and when finished a new timer for 1hour is set.

For more info about the once per hour see #89 #83 and #49

@rdgout @developmentzonneplan is there a API endpoint we can call to get the meta data that's part of the user-accounts/me endpoint without calling the accounts/me? We are interested in the pv totals

  • total_power_measured
  • last_measured_power_value

fsaris avatar Jan 10 '24 13:01 fsaris

@yurnih can't you use yield today? That is updated more often and with more precision.

fsaris avatar Feb 18 '24 13:02 fsaris

Think this will fix the issue https://github.com/fsaris/home-assistant-zonneplan-one/commit/1d628d8d3144ef08f746c0b570b5db336156ff8d please test main version

fsaris avatar Feb 18 '24 16:02 fsaris