Skip to content

Commit

Permalink
Also apply MAC whitelist on (dis-)connect events
Browse files Browse the repository at this point in the history
  • Loading branch information
oxan committed Jan 29, 2023
1 parent db05f8b commit 139d9f3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hapt/files/hapt.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,17 @@ def handle_message(self, interface, message):
self.on_disconnect(interface, components[1])

def on_connect(self, interface, mac):
if 'track_mac_address' in self.config and mac not in self.config['track_mac_address']:
return
if mac not in self.clients:
self.clients[mac] = set()
self.clients[mac].add(interface)
print("Connect of %s on %s, now connected to: %s" % (mac, interface, ", ".join(self.clients[mac])))
self.call_home_assistant(mac, int(self.config['consider_home_connect']))

def on_disconnect(self, interface, mac):
if 'track_mac_address' in self.config and mac not in self.config['track_mac_address']:
return
self.clients[mac].remove(interface)
print("Disconnect of %s on %s, now connected to: %s" % (mac, interface, ", ".join(self.clients[mac])))
if len(self.clients[mac]) == 0:
Expand Down

0 comments on commit 139d9f3

Please sign in to comment.