Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
74b19564
Unverified
Commit
74b19564
authored
1 year ago
by
tronikos
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix Opower not refreshing statistics when there are no forecast entities (#103058)
Ensure _insert_statistics is periodically called
parent
7b691088
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
homeassistant/components/opower/coordinator.py
+13
-1
13 additions, 1 deletion
homeassistant/components/opower/coordinator.py
with
13 additions
and
1 deletion
homeassistant/components/opower/coordinator.py
+
13
−
1
View file @
74b19564
...
@@ -23,7 +23,7 @@ from homeassistant.components.recorder.statistics import (
...
@@ -23,7 +23,7 @@ from homeassistant.components.recorder.statistics import (
statistics_during_period
,
statistics_during_period
,
)
)
from
homeassistant.const
import
CONF_PASSWORD
,
CONF_USERNAME
,
UnitOfEnergy
,
UnitOfVolume
from
homeassistant.const
import
CONF_PASSWORD
,
CONF_USERNAME
,
UnitOfEnergy
,
UnitOfVolume
from
homeassistant.core
import
HomeAssistant
from
homeassistant.core
import
HomeAssistant
,
callback
from
homeassistant.exceptions
import
ConfigEntryAuthFailed
from
homeassistant.exceptions
import
ConfigEntryAuthFailed
from
homeassistant.helpers
import
aiohttp_client
from
homeassistant.helpers
import
aiohttp_client
from
homeassistant.helpers.update_coordinator
import
DataUpdateCoordinator
from
homeassistant.helpers.update_coordinator
import
DataUpdateCoordinator
...
@@ -58,6 +58,16 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
...
@@ -58,6 +58,16 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
entry_data
.
get
(
CONF_TOTP_SECRET
),
entry_data
.
get
(
CONF_TOTP_SECRET
),
)
)
@callback
def
_dummy_listener
()
->
None
:
pass
# Force the coordinator to periodically update by registering at least one listener.
# Needed when the _async_update_data below returns {} for utilities that don't provide
# forecast, which results to no sensors added, no registered listeners, and thus
# _async_update_data not periodically getting called which is needed for _insert_statistics.
self
.
async_add_listener
(
_dummy_listener
)
async
def
_async_update_data
(
async
def
_async_update_data
(
self
,
self
,
)
->
dict
[
str
,
Forecast
]:
)
->
dict
[
str
,
Forecast
]:
...
@@ -71,6 +81,8 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
...
@@ -71,6 +81,8 @@ class OpowerCoordinator(DataUpdateCoordinator[dict[str, Forecast]]):
raise
ConfigEntryAuthFailed
from
err
raise
ConfigEntryAuthFailed
from
err
forecasts
:
list
[
Forecast
]
=
await
self
.
api
.
async_get_forecast
()
forecasts
:
list
[
Forecast
]
=
await
self
.
api
.
async_get_forecast
()
_LOGGER
.
debug
(
"
Updating sensor data with: %s
"
,
forecasts
)
_LOGGER
.
debug
(
"
Updating sensor data with: %s
"
,
forecasts
)
# Because Opower provides historical usage/cost with a delay of a couple of days
# we need to insert data into statistics.
await
self
.
_insert_statistics
()
await
self
.
_insert_statistics
()
return
{
forecast
.
account
.
utility_account_id
:
forecast
for
forecast
in
forecasts
}
return
{
forecast
.
account
.
utility_account_id
:
forecast
for
forecast
in
forecasts
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment