home-assistant / home-assistant.io

:blue_book: Home Assistant User documentation
https://www.home-assistant.io
Other
5k stars 7.3k forks source link

Duke Energy Integration - Data one day offset since time change #35666

Open TrackGeeks opened 1 week ago

TrackGeeks commented 1 week ago

Feedback

I'm having an issue with the data being offset by a day. This started with the change to standard time last weekend. Until the time change, the data was correct. Now there is a gap in the data and everything is off by a day. Will this correct itself or is there something I need to do on my end?

image image image

URL

https://www.home-assistant.io/integrations/duke_energy/

Version

2024.11.1

Additional information

No response

home-assistant[bot] commented 1 week ago

Hey there @hunterjm, mind taking a look at this feedback as it has been labeled with an integration (duke_energy) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `duke_energy` can trigger bot actions by commenting: - `@home-assistant close` Closes the feedback. - `@home-assistant rename Awesome new title` Renames the feedback. - `@home-assistant reopen` Reopen the feedback. - `@home-assistant unassign duke_energy` Removes the current integration label and assignees on the feedback, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information) to the feedback. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information) on the feedback.
DallasEpperson commented 3 days ago

@hunterjm I think this error might stem from how aiodukeenergy is handling the json response from Duke during a "clock change day."

For November 3, Duke's response contains 25 entries in the TickSeries and Series1 arrays instead of the expected 24.

TickSeries: ["12 AM", "01 AM", "01 AM", "02 AM", "03 AM", "04 AM", "05 AM", "06 AM", "07 AM", "08 AM", "09 AM",…]

(Note the duplicated "01 AM")

During the 24 hour range loop, the code is expecting the TickSeries array to be a 1:1 match with the 24 hours of expected_series. If this entry in TickSeries doesn't match our next expected hour from expected_series, the code is marking this hour as missing and adding an hour to the offset. Thus once it encounters the duplicate ("01 AM" for me), everything that comes after is marked as missing.

A simple fix without getting into timezone conversion, etc might be to detect duplicates in the TickSeries array. If one is found, remove that position from TickSeries and Series1 (and 2 if you're using that). It's not a perfect solution as you are missing out on data from that "leap hour" but it should solve this issue without going down the time conversion rabbit hole.