Added try/catch to test if the thread is not killed by exception
This commit is contained in:
parent
c78818bc5c
commit
0b136075de
13
src/main.py
13
src/main.py
|
|
@ -4,7 +4,7 @@ import logging
|
|||
import os
|
||||
|
||||
import paho.mqtt.client
|
||||
from huawei_solar import AsyncHuaweiSolar
|
||||
from huawei_solar import AsyncHuaweiSolar, ReadException
|
||||
from huawei_solar import register_values as rv
|
||||
|
||||
from src.data import InverterData, ReadRegister
|
||||
|
|
@ -37,9 +37,14 @@ async def main():
|
|||
inverter_client = await get_inverter_client()
|
||||
count = 0
|
||||
while True:
|
||||
status = await inverter_client.get(
|
||||
ReadRegister.inverter_reg_status, slave_id
|
||||
)
|
||||
try:
|
||||
status = await inverter_client.get(
|
||||
ReadRegister.inverter_reg_status, slave_id
|
||||
)
|
||||
except ReadException as error:
|
||||
LOGGER.error(f"Can't read register, {ReadRegister.inverter_reg_status}. "
|
||||
f"Error code: {error}. Sleep for 10 min")
|
||||
await asyncio.sleep(10*60)
|
||||
|
||||
LOGGER.info(f"-- INVERTER -- Status: {status}")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue