home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
4.06k stars 2.78k forks source link

Solar forecast and production graph is not correctly aligned in time axis #10394

Closed javitonino closed 2 years ago

javitonino commented 3 years ago

Checklist

Describe the issue you are experiencing

The solar forecast production and forecast graph is not correctly aligned. The forecast line is 1 hour later than it should be. This is what it looks like in my installation.

imagen

Describe the behavior you expected

I expect the forecast to be closer to the actual production values. This is what it looks like if I shift the solar forecast by one hour (by doing time -= 3600000 in the javascript console while rendering the graph):

imagen

I think the problems comes from how the timestamp is picked for each data source:

Steps to reproduce the issue

  1. Configure the energy component with a source of data for photovoltaic production and forecast
  2. Wait to gather some data
  3. Observe that the forecast always seems to be shifted by one hour in time

What version of Home Assistant Core has the issue?

2021.10.6

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

Firefox 93.0

Which operating system are you using to run this browser?

Arch Linux

State of relevant entities

No response

Problem-relevant frontend configuration

Using the energy component to display solar production and forecast.

Solar production comes from a photovoltaic power sensor in Fronius integration. Since this reports power, I use a integration platform to sum the data into energy values per hour.
Solar forecast uses the default forecast.solar integration.

Javascript errors shown in your browser console/inspector

No response

Additional information

I think there are two possible solutions:

The changes should be easy enough. I'll try to set up the development environment and test both approaches in order to submit a PR later this week if I get some time 🤞.

bramkragten commented 3 years ago

Solar production comes from a photovoltaic power sensor in Fronius integration. Since this reports power, I use a integration platform to sum the data into energy values per hour.

Wait, you update the energy sensor value ones an hour? When do you do that?

bramkragten commented 3 years ago

For me personally, the forecast and production do line up correctly, so I'm not sure if your analysis is correct, I'll do some research.

bramkragten commented 3 years ago

(btw, maybe stupid question, are your browser and home assistant in the timezone of your solar panels location?)

javitonino commented 3 years ago

Wait, you update the energy sensor value ones an hour? When do you do that?

It's done continuously, by adding up the power values. It's achieved with the integration sensor: https://www.home-assistant.io/integrations/integration/. My PV system does not report the energy values (only power), so this basically calculates an integral of the power over time to get the energy.

(btw, maybe stupid question, are your browser and home assistant in the timezone of your solar panels location?)

There are no stupid questions :). Yes, everything is in the same timezone.

For me personally, the forecast and production do line up correctly, so I'm not sure if your analysis is correct, I'll do some research.

Hmmm, it's possible that this is caused by some weirdness with the sensors, but it really seems like a graphing issue. Maybe the graph makes some assumptions that do not hold in my configuration.

I have verified the following data manually:

I am assuming that the PV production data is correct and that the solar forecast one is shifted based on the legend that appears on hover. Can you check if you get reasonable start/end times in that tooltip? Are your bars also centered around the start time of the measured period?

Otherwise, in my configuration, it would make sense that the incorrect data is from the production sensors because it's using the integration platform which is probably less used. The solar forecast integration should be pretty much the same in all configurations, so it should be less problematic.

Maybe there is a bug with the legend here? I may have a misconfiguration regarding the production values and the solar forecast may be alright. I'm only assumming the problem is in the forecast because of that tooltip.

KNXBroker commented 3 years ago

I have recognized the same.

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.