mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fix rainforest eagle incorrectly fetch conncted first try (#55193)
This commit is contained in:
parent
bf1112bc10
commit
186b8d4f4b
@ -136,23 +136,28 @@ class EagleDataCoordinator(DataUpdateCoordinator):
|
|||||||
|
|
||||||
async def _async_update_data_200(self):
|
async def _async_update_data_200(self):
|
||||||
"""Get the latest data from the Eagle-200 device."""
|
"""Get the latest data from the Eagle-200 device."""
|
||||||
if self.eagle200_meter is None:
|
eagle200_meter = self.eagle200_meter
|
||||||
|
|
||||||
|
if eagle200_meter is None:
|
||||||
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.entry.data[CONF_INSTALL_CODE],
|
||||||
host=self.entry.data[CONF_HOST],
|
host=self.entry.data[CONF_HOST],
|
||||||
)
|
)
|
||||||
self.eagle200_meter = aioeagle.ElectricMeter.create_instance(
|
eagle200_meter = aioeagle.ElectricMeter.create_instance(
|
||||||
hub, self.hardware_address
|
hub, self.hardware_address
|
||||||
)
|
)
|
||||||
|
is_connected = True
|
||||||
is_connected = self.eagle200_meter.is_connected
|
else:
|
||||||
|
is_connected = eagle200_meter.is_connected
|
||||||
|
|
||||||
async with async_timeout.timeout(30):
|
async with async_timeout.timeout(30):
|
||||||
data = await self.eagle200_meter.get_device_query()
|
data = await eagle200_meter.get_device_query()
|
||||||
|
|
||||||
if is_connected and not self.eagle200_meter.is_connected:
|
if self.eagle200_meter is None:
|
||||||
|
self.eagle200_meter = eagle200_meter
|
||||||
|
elif is_connected and not eagle200_meter.is_connected:
|
||||||
_LOGGER.warning("Lost connection with electricity meter")
|
_LOGGER.warning("Lost connection with electricity meter")
|
||||||
|
|
||||||
_LOGGER.debug("API data: %s", data)
|
_LOGGER.debug("API data: %s", data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user