Skip to content

Commit 139d9f3

Browse files
committed
Also apply MAC whitelist on (dis-)connect events
1 parent db05f8b commit 139d9f3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

hapt/files/hapt.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,17 @@ def handle_message(self, interface, message):
224224
self.on_disconnect(interface, components[1])
225225

226226
def on_connect(self, interface, mac):
227+
if 'track_mac_address' in self.config and mac not in self.config['track_mac_address']:
228+
return
227229
if mac not in self.clients:
228230
self.clients[mac] = set()
229231
self.clients[mac].add(interface)
230232
print("Connect of %s on %s, now connected to: %s" % (mac, interface, ", ".join(self.clients[mac])))
231233
self.call_home_assistant(mac, int(self.config['consider_home_connect']))
232234

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

0 commit comments

Comments
 (0)