Community discussions

 
SledgeHammer
just joined
Topic Author
Posts: 1
Joined: Mon Nov 19, 2018 4:30 pm

Presence detection for domotics

Mon Nov 19, 2018 4:38 pm

Hi,

i looking for a way to check if a MAC address is connected by WiFi and when the last activity was, preferably via Python.
I want to use it as an alive monitor for IOT devices (like ESP32) and for Presence detection of family member (home/away via their smartphones).

Can somebody help me on the way please?

I have found librouterOS that facilitates commands and I think maybe via arp list or torch I may have success.
Preferably a system that is "energy friendly" on de remote device (eg no ping ...).

TIA

Mario
 
Sarel0092
newbie
Posts: 39
Joined: Tue Aug 07, 2018 8:25 am

Re: Presence detection for domotics

Tue Jan 29, 2019 2:57 pm

You can try the below code:

import paramiko
ssh = paramiko.SSHClient()

ip_0 = 'router ip address'
user_0 = 'username'
pass_0 = 'password'
com_0 = 'ip dhcp-server lease print'
#com_0 = 'ip dhcp-server lease print where mac-address=XX:XX:XX:XX:XX:XX' # Add the MAC address of the device
com_1 = 'ip arp print'
#com_1 = 'ip arp print where mac-address=XX:XX:XX:XX:XX:XX' # Add the MAC address of the device

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip_0, port=5252, username=user_0, password=pass_0)
stdin, stdout, stderr = ssh.exec_command(com_0 + '\n' + com_1)
output = stdout.readlines()
type(output)
print('\n'.join(output))
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1303
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: Presence detection for domotics

Tue Jan 29, 2019 11:02 pm

All you ask for I have setup using Mikrotik->Splunk monitor.
To see if some is only, I look at the DNS request, since this is going on nearly all the time when a user is connected.
This way I pick up both cabled and wifi clients.

Si link in my signature.
or this link viewtopic.php?t=137338
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 

Who is online

Users browsing this forum: No registered users and 10 guests