This commit is contained in:
Andrey
2021-02-18 09:27:40 +03:00
parent fcce9dcfc1
commit 358d29f8fd
3 changed files with 22 additions and 15 deletions

View File

@@ -48,6 +48,8 @@ class BaseMegaEntity(CoordinatorEntity, RestoreEntity):
index=None,
):
super().__init__(mega.updater)
if self.http_cmd == 'ds2413':
self.mega.ds2413_ports |= {self.port}
self._state: State = None
self.port = port
self.config_entry = config_entry

View File

@@ -101,6 +101,7 @@ class MegaD:
self.cnd = asyncio.Condition()
self.online = True
self.entities: typing.List[BaseMegaEntity] = []
self.ds2413_ports = set()
self.poll_interval = scan_interval
self.subs = None
self.lg: logging.Logger = lg.getChild(self.id)
@@ -191,25 +192,26 @@ class MegaD:
)
self.online = True
async def _get_ds2413(self):
"""
обновление ds2413 устройств
:return:
"""
for x in self.ds2413_ports:
if x.http_cmd == 'ds2413':
self.lg.debug(f'poll ds2413 for %s', x)
await self.get_port(
port=x,
force_http=True,
http_cmd='list',
conv=False
)
async def poll(self):
"""
Polling ports
"""
self.lg.debug('poll')
ds2413_polled = []
for x in self.entities:
# обновление ds2413 устройств
if x.http_cmd == 'ds2413':
self.lg.debug(f'poll ds2413 for {x.entity_id}')
if x.port in ds2413_polled:
continue
await self.get_port(
port=x.port,
force_http=True,
http_cmd='list',
conv=False
)
ds2413_polled.append(x.port)
if self.mqtt is None:
await self.get_all_ports()
await self.get_sensors(only_list=True)
@@ -219,6 +221,7 @@ class MegaD:
await self.get_sensors()
else:
await self.get_port(self.port_to_scan)
await self._get_ds2413()
return self.values
async def get_mqtt_id(self):
@@ -313,6 +316,8 @@ class MegaD:
if not self.mqtt_inputs:
ret = await self.request(cmd='all')
for port, x in enumerate(ret.split(';')):
if port in self.ds2413_ports:
continue
if check_skip and not port in self.ports:
continue
ret = self.parse_response(x)

View File

@@ -15,5 +15,5 @@
"@andvikt"
],
"issue_tracker": "https://github.com/andvikt/mega_hacs/issues",
"version": "v0.4.1b3"
"version": "v0.4.1b7"
}