don't send AT or Modbus cmds on closed connections

This commit is contained in:
Stefan Allius
2024-05-07 18:32:56 +02:00
parent 39beb0cb44
commit 02d9f01947
3 changed files with 8 additions and 4 deletions

View File

@@ -130,7 +130,7 @@ class Mqtt(metaclass=Singleton):
topic = str(message.topic)
node_id = topic.split('/')[1] + '/'
for m in Message:
if m.server_side and m.node_id == node_id:
if m.server_side and not m.closed and (m.node_id == node_id):
logger_mqtt.debug(f'Found: {node_id}')
fnc = getattr(m, func_name, None)
if callable(fnc):
@@ -148,7 +148,7 @@ class Mqtt(metaclass=Singleton):
payload = message.payload.decode("UTF-8")
logger_mqtt.info(f'InvCnf: {node_id}:{payload}')
for m in Message:
if m.server_side and m.node_id == node_id:
if m.server_side and not m.closed and (m.node_id == node_id):
logger_mqtt.info(f'Found: {node_id}')
fnc = getattr(m, "send_modbus_cmd", None)
res = payload.split(',')