Merge pull request #88 from Patrick762/pack-polling
Check pack_num only once
This commit is contained in:
1 file changed
+15
-11
@@ -110,6 +110,8 @@ class DeviceReader:
|
|||||||
# We need to wait after switching packs for the data to be available
|
# We need to wait after switching packs for the data to be available
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
|
|
||||||
|
pack_ok = False
|
||||||
|
|
||||||
for command in pack_commands:
|
for command in pack_commands:
|
||||||
# Request & parse result for each pack
|
# Request & parse result for each pack
|
||||||
try:
|
try:
|
||||||
@@ -121,17 +123,19 @@ class DeviceReader:
|
|||||||
)
|
)
|
||||||
_LOGGER.debug("Parsed data: %s", parsed)
|
_LOGGER.debug("Parsed data: %s", parsed)
|
||||||
|
|
||||||
pack_number = parsed.get("pack_num")
|
if not pack_ok: # Only check this once
|
||||||
if (
|
pack_number = parsed.get("pack_num")
|
||||||
not isinstance(pack_number, int)
|
if (
|
||||||
or pack_number != pack
|
not isinstance(pack_number, int)
|
||||||
):
|
or pack_number != pack
|
||||||
_LOGGER.debug(
|
):
|
||||||
"Parsed pack_num(%s) does not match expected '%s'",
|
_LOGGER.debug(
|
||||||
pack_number,
|
"Parsed pack_num(%s) does not match expected '%s'",
|
||||||
pack,
|
pack_number,
|
||||||
)
|
pack,
|
||||||
continue
|
)
|
||||||
|
continue
|
||||||
|
pack_ok = True
|
||||||
|
|
||||||
for key, value in parsed.items():
|
for key, value in parsed.items():
|
||||||
parsed_data.update({key + str(pack): value})
|
parsed_data.update({key + str(pack): value})
|
||||||
|
|||||||
Reference in new issue
Block a user