code cleanup

This commit is contained in:
Michael Clemens 2020-12-08 12:19:16 +01:00
parent f15c5a18ad
commit b56f9d839f
1 changed files with 10 additions and 7 deletions

View File

@ -49,7 +49,7 @@ def on_mqtt(*args):
callsign = call["SourceCall"]
start_time = call["Start"]
stop_time = call["Stop"]
msg = ""
notify = False
now = int(time.time())
# check if callsign is monitored, the transmission has already been finished
# and the person was inactive for n seconds
@ -63,10 +63,11 @@ def on_mqtt(*args):
last_TG_activity[tg] = now
# remember the transmission time stamp of this particular DMR user
last_OM_activity[callsign] = now
msg = construct_message(call)
#msg = construct_message(call)
notify = True
# Continue if the talkgroup is monitored, the transmission has been finished and there was no activity
# during the last n seconds in this talkgroup
elif tg in cfg.talkgroups and stop_time > 0 and callsign not in cfg.noisy_calls:
elif tg in cfg.talkgroups and stop_time > 0:# and callsign not in cfg.noisy_calls:
if tg not in last_TG_activity:
last_TG_activity[tg] = 9999999
inactivity = now - last_TG_activity[tg]
@ -75,16 +76,18 @@ def on_mqtt(*args):
# only proceed if the key down has been long enough
if duration >= cfg.min_duration:
if tg not in last_TG_activity or inactivity >= cfg.min_silence:
msg = construct_message(call)
#msg = construct_message(call)
notify = True
elif cfg.verbose:
print("ignored activity in TG " + str(tg) + " from " + callsign + ": last action " + str(inactivity) + " seconds ago.")
last_TG_activity[tg] = now
if cfg.verbose and callsign in cfg.noisy_calls:
print("ignored noisy ham " + callsign)
# finally write the message to the console and send a push notification
if msg != "":
print(construct_message(call))
push_message(construct_message(call))
if notify:
msg = construct_message(call)
print(msg)
push_message(msg)
socket = SocketIO('https://api.brandmeister.network/lh')
socket.on('connect', on_connect)