Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S allius/issue131 #132

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/src/async_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __timeout(self) -> int:
to = self.MAX_CLOUD_IDLE_TIME
return to

async def __publish_outstanding_mqtt(self):
async def publish_outstanding_mqtt(self):
'''Publish all outstanding MQTT topics'''
try:
if self.unique_id:
Expand All @@ -58,10 +58,10 @@ async def server_loop(self, addr: str) -> None:
logger.info(f'[{self.node_id}:{self.conn_no}] '
f'Accept connection from {addr}')
self.inc_counter('Inverter_Cnt')
await self.__publish_outstanding_mqtt()
await self.publish_outstanding_mqtt()
await self.loop()
self.dec_counter('Inverter_Cnt')
await self.__publish_outstanding_mqtt()
await self.publish_outstanding_mqtt()
logger.info(f'[{self.node_id}:{self.conn_no}] Server loop stopped for'
f' r{self.r_addr}')

Expand Down
2 changes: 2 additions & 0 deletions app/src/modbus_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ async def __aenter__(self) -> 'InverterG3P':
logging.info(f'[{self.stream.node_id}:{self.stream.conn_no}] '
f'Connected to {self.addr}')
self.stream.inc_counter('Inverter_Cnt')
await self.stream.publish_outstanding_mqtt()
return self.stream

async def __aexit__(self, exc_type, exc, tb):
self.stream.dec_counter('Inverter_Cnt')
await self.stream.publish_outstanding_mqtt()


class ModbusTcp():
Expand Down