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
42701312
Unverified
Commit
42701312
authored
2 months ago
by
Michael
Committed by
GitHub
2 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Explicitly pass in the config_entry in iron_os coordinator (#138137)
explicitly pass in the config_entry in coordinator
parent
5dea4164
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
homeassistant/components/iron_os/__init__.py
+3
-4
3 additions, 4 deletions
homeassistant/components/iron_os/__init__.py
homeassistant/components/iron_os/coordinator.py
+37
-28
37 additions, 28 deletions
homeassistant/components/iron_os/coordinator.py
with
40 additions
and
32 deletions
homeassistant/components/iron_os/__init__.py
+
3
−
4
View file @
42701312
...
@@ -8,7 +8,6 @@ from typing import TYPE_CHECKING
...
@@ -8,7 +8,6 @@ from typing import TYPE_CHECKING
from
pynecil
import
IronOSUpdate
,
Pynecil
from
pynecil
import
IronOSUpdate
,
Pynecil
from
homeassistant.components
import
bluetooth
from
homeassistant.components
import
bluetooth
from
homeassistant.config_entries
import
ConfigEntry
from
homeassistant.const
import
CONF_NAME
,
Platform
from
homeassistant.const
import
CONF_NAME
,
Platform
from
homeassistant.core
import
HomeAssistant
from
homeassistant.core
import
HomeAssistant
from
homeassistant.exceptions
import
ConfigEntryNotReady
from
homeassistant.exceptions
import
ConfigEntryNotReady
...
@@ -19,6 +18,7 @@ from homeassistant.util.hass_dict import HassKey
...
@@ -19,6 +18,7 @@ from homeassistant.util.hass_dict import HassKey
from
.const
import
DOMAIN
from
.const
import
DOMAIN
from
.coordinator
import
(
from
.coordinator
import
(
IronOSConfigEntry
,
IronOSCoordinators
,
IronOSCoordinators
,
IronOSFirmwareUpdateCoordinator
,
IronOSFirmwareUpdateCoordinator
,
IronOSLiveDataCoordinator
,
IronOSLiveDataCoordinator
,
...
@@ -39,7 +39,6 @@ PLATFORMS: list[Platform] = [
...
@@ -39,7 +39,6 @@ PLATFORMS: list[Platform] = [
CONFIG_SCHEMA
=
cv
.
config_entry_only_config_schema
(
DOMAIN
)
CONFIG_SCHEMA
=
cv
.
config_entry_only_config_schema
(
DOMAIN
)
type
IronOSConfigEntry
=
ConfigEntry
[
IronOSCoordinators
]
IRON_OS_KEY
:
HassKey
[
IronOSFirmwareUpdateCoordinator
]
=
HassKey
(
DOMAIN
)
IRON_OS_KEY
:
HassKey
[
IronOSFirmwareUpdateCoordinator
]
=
HassKey
(
DOMAIN
)
...
@@ -73,10 +72,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: IronOSConfigEntry) -> bo
...
@@ -73,10 +72,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: IronOSConfigEntry) -> bo
device
=
Pynecil
(
ble_device
)
device
=
Pynecil
(
ble_device
)
live_data
=
IronOSLiveDataCoordinator
(
hass
,
device
)
live_data
=
IronOSLiveDataCoordinator
(
hass
,
entry
,
device
)
await
live_data
.
async_config_entry_first_refresh
()
await
live_data
.
async_config_entry_first_refresh
()
settings
=
IronOSSettingsCoordinator
(
hass
,
device
)
settings
=
IronOSSettingsCoordinator
(
hass
,
entry
,
device
)
await
settings
.
async_config_entry_first_refresh
()
await
settings
.
async_config_entry_first_refresh
()
entry
.
runtime_data
=
IronOSCoordinators
(
entry
.
runtime_data
=
IronOSCoordinators
(
...
...
This diff is collapsed.
Click to expand it.
homeassistant/components/iron_os/coordinator.py
+
37
−
28
View file @
42701312
...
@@ -43,15 +43,19 @@ class IronOSCoordinators:
...
@@ -43,15 +43,19 @@ class IronOSCoordinators:
settings
:
IronOSSettingsCoordinator
settings
:
IronOSSettingsCoordinator
type
IronOSConfigEntry
=
ConfigEntry
[
IronOSCoordinators
]
class
IronOSBaseCoordinator
[
_DataT
](
DataUpdateCoordinator
[
_DataT
]):
class
IronOSBaseCoordinator
[
_DataT
](
DataUpdateCoordinator
[
_DataT
]):
"""
IronOS base coordinator.
"""
"""
IronOS base coordinator.
"""
device_info
:
DeviceInfoResponse
device_info
:
DeviceInfoResponse
config_entry
:
ConfigEntry
config_entry
:
IronOS
ConfigEntry
def
__init__
(
def
__init__
(
self
,
self
,
hass
:
HomeAssistant
,
hass
:
HomeAssistant
,
config_entry
:
IronOSConfigEntry
,
device
:
Pynecil
,
device
:
Pynecil
,
update_interval
:
timedelta
,
update_interval
:
timedelta
,
)
->
None
:
)
->
None
:
...
@@ -60,6 +64,7 @@ class IronOSBaseCoordinator[_DataT](DataUpdateCoordinator[_DataT]):
...
@@ -60,6 +64,7 @@ class IronOSBaseCoordinator[_DataT](DataUpdateCoordinator[_DataT]):
super
().
__init__
(
super
().
__init__
(
hass
,
hass
,
_LOGGER
,
_LOGGER
,
config_entry
=
config_entry
,
name
=
DOMAIN
,
name
=
DOMAIN
,
update_interval
=
update_interval
,
update_interval
=
update_interval
,
request_refresh_debouncer
=
Debouncer
(
request_refresh_debouncer
=
Debouncer
(
...
@@ -80,9 +85,11 @@ class IronOSBaseCoordinator[_DataT](DataUpdateCoordinator[_DataT]):
...
@@ -80,9 +85,11 @@ class IronOSBaseCoordinator[_DataT](DataUpdateCoordinator[_DataT]):
class
IronOSLiveDataCoordinator
(
IronOSBaseCoordinator
[
LiveDataResponse
]):
class
IronOSLiveDataCoordinator
(
IronOSBaseCoordinator
[
LiveDataResponse
]):
"""
IronOS coordinator.
"""
"""
IronOS coordinator.
"""
def
__init__
(
self
,
hass
:
HomeAssistant
,
device
:
Pynecil
)
->
None
:
def
__init__
(
self
,
hass
:
HomeAssistant
,
config_entry
:
IronOSConfigEntry
,
device
:
Pynecil
)
->
None
:
"""
Initialize IronOS coordinator.
"""
"""
Initialize IronOS coordinator.
"""
super
().
__init__
(
hass
,
device
=
device
,
update_interval
=
SCAN_INTERVAL
)
super
().
__init__
(
hass
,
config_entry
,
device
,
SCAN_INTERVAL
)
async
def
_async_update_data
(
self
)
->
LiveDataResponse
:
async
def
_async_update_data
(
self
)
->
LiveDataResponse
:
"""
Fetch data from Device.
"""
"""
Fetch data from Device.
"""
...
@@ -109,35 +116,14 @@ class IronOSLiveDataCoordinator(IronOSBaseCoordinator[LiveDataResponse]):
...
@@ -109,35 +116,14 @@ class IronOSLiveDataCoordinator(IronOSBaseCoordinator[LiveDataResponse]):
return
False
return
False
class
IronOSFirmwareUpdateCoordinator
(
DataUpdateCoordinator
[
LatestRelease
]):
"""
IronOS coordinator for retrieving update information from github.
"""
def
__init__
(
self
,
hass
:
HomeAssistant
,
github
:
IronOSUpdate
)
->
None
:
"""
Initialize IronOS coordinator.
"""
super
().
__init__
(
hass
,
_LOGGER
,
config_entry
=
None
,
name
=
DOMAIN
,
update_interval
=
SCAN_INTERVAL_GITHUB
,
)
self
.
github
=
github
async
def
_async_update_data
(
self
)
->
LatestRelease
:
"""
Fetch data from Github.
"""
try
:
return
await
self
.
github
.
latest_release
()
except
UpdateException
as
e
:
raise
UpdateFailed
(
"
Failed to check for latest IronOS update
"
)
from
e
class
IronOSSettingsCoordinator
(
IronOSBaseCoordinator
[
SettingsDataResponse
]):
class
IronOSSettingsCoordinator
(
IronOSBaseCoordinator
[
SettingsDataResponse
]):
"""
IronOS coordinator.
"""
"""
IronOS coordinator.
"""
def
__init__
(
self
,
hass
:
HomeAssistant
,
device
:
Pynecil
)
->
None
:
def
__init__
(
self
,
hass
:
HomeAssistant
,
config_entry
:
IronOSConfigEntry
,
device
:
Pynecil
)
->
None
:
"""
Initialize IronOS coordinator.
"""
"""
Initialize IronOS coordinator.
"""
super
().
__init__
(
hass
,
device
=
device
,
update_interval
=
SCAN_INTERVAL_SETTINGS
)
super
().
__init__
(
hass
,
config_entry
,
device
,
SCAN_INTERVAL_SETTINGS
)
async
def
_async_update_data
(
self
)
->
SettingsDataResponse
:
async
def
_async_update_data
(
self
)
->
SettingsDataResponse
:
"""
Fetch data from Device.
"""
"""
Fetch data from Device.
"""
...
@@ -173,3 +159,26 @@ class IronOSSettingsCoordinator(IronOSBaseCoordinator[SettingsDataResponse]):
...
@@ -173,3 +159,26 @@ class IronOSSettingsCoordinator(IronOSBaseCoordinator[SettingsDataResponse]):
)
)
self
.
async_update_listeners
()
self
.
async_update_listeners
()
await
self
.
async_request_refresh
()
await
self
.
async_request_refresh
()
class
IronOSFirmwareUpdateCoordinator
(
DataUpdateCoordinator
[
LatestRelease
]):
"""
IronOS coordinator for retrieving update information from github.
"""
def
__init__
(
self
,
hass
:
HomeAssistant
,
github
:
IronOSUpdate
)
->
None
:
"""
Initialize IronOS coordinator.
"""
super
().
__init__
(
hass
,
_LOGGER
,
config_entry
=
None
,
name
=
DOMAIN
,
update_interval
=
SCAN_INTERVAL_GITHUB
,
)
self
.
github
=
github
async
def
_async_update_data
(
self
)
->
LatestRelease
:
"""
Fetch data from Github.
"""
try
:
return
await
self
.
github
.
latest_release
()
except
UpdateException
as
e
:
raise
UpdateFailed
(
"
Failed to check for latest IronOS update
"
)
from
e
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