mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Explicitly pass in the config_entry in rainforest_eagle coordinator (#137981)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
133fdb0ed2
commit
f30018d89e
@ -29,13 +29,13 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
class EagleDataCoordinator(DataUpdateCoordinator):
|
class EagleDataCoordinator(DataUpdateCoordinator):
|
||||||
"""Get the latest data from the Eagle device."""
|
"""Get the latest data from the Eagle device."""
|
||||||
|
|
||||||
|
config_entry: ConfigEntry
|
||||||
eagle100_reader: Eagle100Reader | None = None
|
eagle100_reader: Eagle100Reader | None = None
|
||||||
eagle200_meter: aioeagle.ElectricMeter | None = None
|
eagle200_meter: aioeagle.ElectricMeter | None = None
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
|
def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry) -> None:
|
||||||
"""Initialize the data object."""
|
"""Initialize the data object."""
|
||||||
self.entry = entry
|
if config_entry.data[CONF_TYPE] == TYPE_EAGLE_100:
|
||||||
if self.type == TYPE_EAGLE_100:
|
|
||||||
self.model = "EAGLE-100"
|
self.model = "EAGLE-100"
|
||||||
update_method = self._async_update_data_100
|
update_method = self._async_update_data_100
|
||||||
else:
|
else:
|
||||||
@ -45,7 +45,8 @@ class EagleDataCoordinator(DataUpdateCoordinator):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
name=entry.data[CONF_CLOUD_ID],
|
config_entry=config_entry,
|
||||||
|
name=config_entry.data[CONF_CLOUD_ID],
|
||||||
update_interval=timedelta(seconds=30),
|
update_interval=timedelta(seconds=30),
|
||||||
update_method=update_method,
|
update_method=update_method,
|
||||||
)
|
)
|
||||||
@ -53,17 +54,12 @@ class EagleDataCoordinator(DataUpdateCoordinator):
|
|||||||
@property
|
@property
|
||||||
def cloud_id(self):
|
def cloud_id(self):
|
||||||
"""Return the cloud ID."""
|
"""Return the cloud ID."""
|
||||||
return self.entry.data[CONF_CLOUD_ID]
|
return self.config_entry.data[CONF_CLOUD_ID]
|
||||||
|
|
||||||
@property
|
|
||||||
def type(self):
|
|
||||||
"""Return entry type."""
|
|
||||||
return self.entry.data[CONF_TYPE]
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hardware_address(self):
|
def hardware_address(self):
|
||||||
"""Return hardware address of meter."""
|
"""Return hardware address of meter."""
|
||||||
return self.entry.data[CONF_HARDWARE_ADDRESS]
|
return self.config_entry.data[CONF_HARDWARE_ADDRESS]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_connected(self):
|
def is_connected(self):
|
||||||
@ -79,8 +75,8 @@ class EagleDataCoordinator(DataUpdateCoordinator):
|
|||||||
hub = aioeagle.EagleHub(
|
hub = aioeagle.EagleHub(
|
||||||
aiohttp_client.async_get_clientsession(self.hass),
|
aiohttp_client.async_get_clientsession(self.hass),
|
||||||
self.cloud_id,
|
self.cloud_id,
|
||||||
self.entry.data[CONF_INSTALL_CODE],
|
self.config_entry.data[CONF_INSTALL_CODE],
|
||||||
host=self.entry.data[CONF_HOST],
|
host=self.config_entry.data[CONF_HOST],
|
||||||
)
|
)
|
||||||
eagle200_meter = aioeagle.ElectricMeter.create_instance(
|
eagle200_meter = aioeagle.ElectricMeter.create_instance(
|
||||||
hub, self.hardware_address
|
hub, self.hardware_address
|
||||||
@ -115,8 +111,8 @@ class EagleDataCoordinator(DataUpdateCoordinator):
|
|||||||
if self.eagle100_reader is None:
|
if self.eagle100_reader is None:
|
||||||
self.eagle100_reader = Eagle100Reader(
|
self.eagle100_reader = Eagle100Reader(
|
||||||
self.cloud_id,
|
self.cloud_id,
|
||||||
self.entry.data[CONF_INSTALL_CODE],
|
self.config_entry.data[CONF_INSTALL_CODE],
|
||||||
self.entry.data[CONF_HOST],
|
self.config_entry.data[CONF_HOST],
|
||||||
)
|
)
|
||||||
|
|
||||||
out = {}
|
out = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user