fixes
- fixes null pointer accesses - initalize AsyncStreamClient with proper StreamPtr instance
This commit is contained in:
@@ -29,13 +29,15 @@ class InverterBase(Inverter):
|
|||||||
port = tsun['port']
|
port = tsun['port']
|
||||||
addr = (host, port)
|
addr = (host, port)
|
||||||
stream = self.local.stream
|
stream = self.local.stream
|
||||||
|
if not stream:
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logging.info(f'[{stream.node_id}] Connect to {addr}')
|
logging.info(f'[{stream.node_id}] Connect to {addr}')
|
||||||
connect = asyncio.open_connection(host, port)
|
connect = asyncio.open_connection(host, port)
|
||||||
reader, writer = await connect
|
reader, writer = await connect
|
||||||
ifc = AsyncStreamClient(reader, writer,
|
ifc = AsyncStreamClient(reader, writer,
|
||||||
self.remote)
|
self.local)
|
||||||
|
|
||||||
if hasattr(stream, 'id_str'):
|
if hasattr(stream, 'id_str'):
|
||||||
self.remote.stream = conn_class(
|
self.remote.stream = conn_class(
|
||||||
@@ -60,7 +62,7 @@ class InverterBase(Inverter):
|
|||||||
async def async_publ_mqtt(self) -> None:
|
async def async_publ_mqtt(self) -> None:
|
||||||
'''publish data to MQTT broker'''
|
'''publish data to MQTT broker'''
|
||||||
stream = self.local.stream
|
stream = self.local.stream
|
||||||
if not stream.unique_id:
|
if not stream or not stream.unique_id:
|
||||||
return
|
return
|
||||||
# check if new inverter or collector infos are available or when the
|
# check if new inverter or collector infos are available or when the
|
||||||
# home assistant has changed the status back to online
|
# home assistant has changed the status back to online
|
||||||
|
|||||||
Reference in New Issue
Block a user