Fall back to daily granularity when the quarter-hour feed is empty (#361)#362
Open
Sgoettschkes wants to merge 1 commit into
Open
Conversation
When a meter is opted into 15-minute values, the integration requests quarter-hour (V002) bewegungsdaten. WienerNetze intermittently returns an empty response (einheit: null) for V002 even though the daily (V001) feed is populated, causing the importer to abort with "Unit of measurement is None! Aborting import..." (DarwinsBuddy#361). Try the configured granularity first and fall back to daily (V001) when the quarter-hour response has no unit of measurement, so 15-minute data is used when available and daily otherwise. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #361.
When a meter is opted into 15-minute values (Viertelstundenwerte), its role flips from
V001(daily) toV002(quarter-hour), andWNSMSensor.granularity()follows the account intoQUARTER_HOUR. WienerNetze can return an empty response for the V002 feed (einheit: null,values: []) even while the dailyV001feed is still populated. The importer then hits:and writes nothing, so the energy dashboard stops updating.
Change
Importer._import_statisticsnow fetches through a small helper_get_bewegungsdaten()that:ValueType.DAY/ V001).So 15-minute data is used whenever WienerNetze serves it, and daily is used as a fallback otherwise. The existing
unitOfMeasurement is Noneguard remains as a final backstop — if even the daily feed is empty, it aborts cleanly as before. Downstream aggregation is unchanged, since values are bucketed hourly regardless of source granularity.The fallback only triggers when the requested granularity isn't already daily and the response has no unit, so a normal incremental cycle with no newly-finalised readings doesn't cause an extra API call.
Testing
Verified on a live Home Assistant instance whose meter was opted into 15-minute values and hitting #361: after the change the integration imports again — using quarter-hour data when WienerNetze serves it, and falling back to daily when the V002 feed comes back empty.