Wi-Fi or network presence-based control

The system can detect whether registered devices are connected to the home network and use this information in the operation of control modules. This allows the automation system to adapt its behavior depending on whether someone is at home.

Presence detection is included in the Szélessáv Műhely OpenWrt firmware, but it can also be installed as a standalone module on a standard OpenWrt system, so no custom firmware is required.

Main features

Installation on a standard OpenWrt router

The presence detection module can be installed directly on a standard OpenWrt system. Connect to the router that will perform presence detection via SSH and run:

wget -qO- https://raw.githubusercontent.com/szelessavalapitvany/openwrt-presence/main/install.sh | sh

The installer automatically detects the package manager, installs the required dependencies, downloads the module files and restarts the required LuCI services.

After installation, a new Smart home menu appears in LuCI:

Smart home ├── Presence ├── Wifi presence └── Access points

The installer can also be run again later to update the module. Existing configuration files under /etc/config/ are preserved, so previously created presence groups and access point settings are not overwritten.

Presence detection methods

The system provides two different methods for determining presence.

Wi-Fi-based presence detection

Network-based presence detection

Smart home presence control

Creating presence groups

Important: group names are case-sensitive, so uppercase and lowercase letters must be used consistently.

Using multiple Wi-Fi access points

Wi-Fi-based presence detection is not limited to the main OpenWrt router. Additional OpenWrt routers or access points can also be included in presence detection.

In addition to its own Wi-Fi clients, the main router can query configured access points for the MAC addresses of devices currently connected to them. This makes it possible to provide unified presence detection in larger homes where several Wi-Fi access points are used.

An access point can be identified in two ways:

Using a fixed IP address is recommended because access to the secondary access point does not then depend on whether it has a DHCP lease entry.

The default REST endpoint is:

/cgi-bin/luci/get-wifi-clients

Installing the Wi-Fi Client API on a secondary router

Every secondary OpenWrt router or access point whose Wi-Fi clients should be visible to the main router must have the OpenWrt Wi-Fi Client API module installed.

The project is available in a separate GitHub repository:

https://github.com/szelessavalapitvany/openwrt-wifi-client-api

Install it on the secondary OpenWrt router with:

wget -qO- https://raw.githubusercontent.com/szelessavalapitvany/openwrt-wifi-client-api/main/install.sh | sh

After installation, the following endpoint becomes available:

http://ROUTER-IP/cgi-bin/luci/get-wifi-clients

The response is a JSON array containing the MAC addresses of the currently connected Wi-Fi clients.

Example:

[ "11:22:33:44:55:66", "AA:BB:CC:DD:EE:FF" ]

MAC address handling and reliable identification

Modern phones and other mobile devices often use randomized or private MAC addresses for privacy reasons.

For reliable presence detection, it is important that the MAC address used for the home Wi-Fi network does not change.

Configuration steps:

  1. Open the Wi-Fi settings on the phone and select the home network.
  2. Find the setting called “Private MAC”, “Randomized MAC” or similar.
  3. Change it to use a fixed or device MAC address.

Integration with other systems

The state of presence groups can also be queried using simple HTTP requests. This means the feature is not limited to the DSVT system and can also be used by other automation platforms.

Network-based presence

http://ROUTER-IP/cgi-bin/luci/presence/GROUPNAME

Wi-Fi-based presence

http://ROUTER-IP/cgi-bin/luci/wifi-presence/GROUPNAME

If at least one client in the group is present, the response is:

true

If none of the clients are present:

false

A successful query returns HTTP status 200. An invalid or non-existent group returns HTTP status 404.

GitHub projects

OpenWrt Presence – presence detection module for the main router:
https://github.com/szelessavalapitvany/openwrt-presence

OpenWrt Wi-Fi Client API – for secondary access points:
https://github.com/szelessavalapitvany/openwrt-wifi-client-api

Summary