mirror of
https://github.com/andvikt/mega_hacs.git
synced 2025-12-11 09:04:27 +05:00
add hex_to_float option
add auto config reload on megad restart fix reloading issues
This commit is contained in:
@@ -77,7 +77,11 @@ class MegaView(HomeAssistantView):
|
||||
if hub is None:
|
||||
_LOGGER.warning(f'can not find mdid={request.query["mdid"]} in {list(self.hubs)}')
|
||||
if hub is None and request.remote in ['::1', '127.0.0.1']:
|
||||
hub = self.hubs.get('__def')
|
||||
try:
|
||||
hub = list(self.hubs.values())[0]
|
||||
except IndexError:
|
||||
_LOGGER.warning(f'can not find mdid={request.query["mdid"]} in {list(self.hubs)}')
|
||||
return Response(status=400)
|
||||
elif hub is None:
|
||||
return Response(status=400)
|
||||
data = dict(request.query)
|
||||
@@ -87,8 +91,10 @@ class MegaView(HomeAssistantView):
|
||||
)
|
||||
_LOGGER.debug(f"Request: %s from '%s'", data, request.remote)
|
||||
make_ints(data)
|
||||
if data.get('st') == '1' and hub.restore_on_restart:
|
||||
asyncio.create_task(self.later_restore(hub))
|
||||
if data.get('st') == '1':
|
||||
hass.async_create_task(hub.reload())
|
||||
if hub.restore_on_restart:
|
||||
hass.async_create_task(self.later_restore(hub))
|
||||
return Response(status=200)
|
||||
port = data.get('pt')
|
||||
data = data.copy()
|
||||
@@ -163,5 +169,4 @@ class MegaView(HomeAssistantView):
|
||||
async def later_update(self, hub):
|
||||
await asyncio.sleep(1)
|
||||
_LOGGER.debug('force update')
|
||||
await hub.updater.async_refresh()
|
||||
|
||||
await hub.updater.async_refresh()
|
||||
Reference in New Issue
Block a user