From f2ade43410aa37be7f512f5af15d03ccea0ce3cf Mon Sep 17 00:00:00 2001 From: Stefan Allius Date: Mon, 30 Sep 2024 19:14:50 +0200 Subject: [PATCH] fixes - fixes null pointer accesses - initalize AsyncStreamClient with proper StreamPtr instance --- app/src/inverter_base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/inverter_base.py b/app/src/inverter_base.py index 5784a2b..ac9ecd7 100644 --- a/app/src/inverter_base.py +++ b/app/src/inverter_base.py @@ -29,13 +29,15 @@ class InverterBase(Inverter): port = tsun['port'] addr = (host, port) stream = self.local.stream + if not stream: + return try: logging.info(f'[{stream.node_id}] Connect to {addr}') connect = asyncio.open_connection(host, port) reader, writer = await connect ifc = AsyncStreamClient(reader, writer, - self.remote) + self.local) if hasattr(stream, 'id_str'): self.remote.stream = conn_class( @@ -60,7 +62,7 @@ class InverterBase(Inverter): async def async_publ_mqtt(self) -> None: '''publish data to MQTT broker''' stream = self.local.stream - if not stream.unique_id: + if not stream or not stream.unique_id: return # check if new inverter or collector infos are available or when the # home assistant has changed the status back to online