Skip to content

Commit

Permalink
Delete "theengs/internal/" condition
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiH committed Jul 3, 2024
1 parent f352339 commit b4dfc94
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions TheengsGateway/ble_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,28 +227,26 @@ def subscribe(self, sub_topic: str) -> None:
"""Subscribe to MQTT topic <sub_topic>."""

def on_message(client, userdata, msg) -> None: # noqa: ANN001,ARG001
# Theengs internal
if "theengs/internal/" in msg.topic:
# Evaluate trackersync messages
if msg.topic == "theengs/internal/trackersync":
msg_json = json.loads(msg.payload)
logger.debug("trackersync message: %s", msg_json)

if (
msg_json["gatewayid"] != self.configuration["gateway_id"]
and msg_json["tracker"] in self.discovered_trackers
and self.discovered_trackers[msg_json["tracker"]].time != 0
):
self.discovered_trackers[msg_json["tracker"]].time = 0
logger.debug(
"Tracker %s disassociated by gateway %s",
msg_json["tracker"],
msg_json["gatewayid"],
)
# Evaluate trackersync messages
if msg.topic == "theengs/internal/trackersync":
msg_json = json.loads(msg.payload)
logger.debug("trackersync message: %s", msg_json)

logger.debug(
"[DIS] Discovered Trackers: %s", self.discovered_trackers
)
if (
msg_json["gatewayid"] != self.configuration["gateway_id"]
and msg_json["tracker"] in self.discovered_trackers
and self.discovered_trackers[msg_json["tracker"]].time != 0
):
self.discovered_trackers[msg_json["tracker"]].time = 0
logger.debug(
"Tracker %s disassociated by gateway %s",
msg_json["tracker"],
msg_json["gatewayid"],
)

logger.debug(
"[DIS] Discovered Trackers: %s", self.discovered_trackers
)
else:
logger.info(
"Received `%s` from `%s` topic",
Expand Down

0 comments on commit b4dfc94

Please sign in to comment.