Skip to content

Commit

Permalink
Fix when MQTT message doesn't have time
Browse files Browse the repository at this point in the history
e.g. when adding users
  • Loading branch information
matjack1 committed Oct 31, 2023
1 parent 0e98022 commit 3191ef0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions TelegramBot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,14 @@ def on_mqtt_message(client, userdata, message):
logging.error(e)
return

message_time = int(_json.get('time'))
if _json.get('time'):
message_time = int(_json.get('time'))

# we skip multiple messages with the same timestamp
if message_time == last_mqtt_message:
same_timestamp_as_previous_message = True
# we skip multiple messages with the same timestamp
if message_time == last_mqtt_message:
same_timestamp_as_previous_message = True

last_mqtt_message = message_time
last_mqtt_message = message_time

_type = _json.get('type')
_access = _json.get('access')
Expand Down

0 comments on commit 3191ef0

Please sign in to comment.