awilliams / wifi-presence Goto Github PK
View Code? Open in Web Editor NEWPresence detection on OpenWrt routers using connect/disconnect events of WiFi clients. Events are published to MQTT with Home Assistant integration.
License: MIT License
Presence detection on OpenWrt routers using connect/disconnect events of WiFi clients. Events are published to MQTT with Home Assistant integration.
License: MIT License
Have you considered adding support for MQTTS? It feels pretty pointless to me to have my routers sending usernames and passwords unencrytped to my MQTT broker.
Thanks for the awesome tool!
Hi Adam,
I've noticed that wifi-presence
does not start cleanly on boot for me. I suspect the issue is that hostapd
hasn't started yet, and there are no control sockets found by wifi-presence
when it starts.
root@ap-office:~# logread | grep wifi-presence
Fri Apr 22 17:08:51 2022 daemon.err wifi-presence[2366]: Error: hostapd.socks cannot be blank
Restarting the process manually after boot is fine, so I'm not sure what the best way of resolving this is, whether it be through procd
, or through wifi-presence
itself.
Cheers,
Jon
@awilliams Thanks for your work, I like your project. I integrated it with my Openhab. Now I can detect myself at home or my wife.
Also, it would be helpful to be able to publish all devices' statuses to the MQTT. My use case is to track guests at my house
Hi Adam,
Thanks for this great integration!
However, my WiFi SSID begins with UTF-8 character and then ASCII one, like ฯ=2ฯf
.
In this case, status
from hostapd_cli
gives something below, which mixes \x
and normal ASCII chars.
ssid[0]=\xcf\x89=2\xcf\x80f
wifi-presence/internal/hostapd/status.go
Lines 58 to 67 in b2b64ea
The code above just replace \x
and then decode hex, which still contains non-hex chars, resulting Error: encoding/hex: invalid byte
on my device. I'm not familiar with golang though, but maybe we could use strconv.Unquote
instead? (Ref)
Thanks
It looks to me JSON configuration is not persistent.
According to my tests it is necessary to publish JSON configuration to the config topic (<mqtt.prefix>/config) every time OpenWrt is rebooted.
Am I missing something?
My configuration:
Model: TP-Link TL-WR2543N/ND
Architecture: Atheros AR7242 rev 1
Firmware Version: OpenWrt 19.07.8 r11364-ef56c85848 / LuCI openwrt-19.07 branch git-21.189.23240-7b931da
Kernel Version:4.14.241
wifi-presence (0.1.1-1)
I'm seeing the following error when I try to build an image with this package installed:
> * check_data_file_clashes: Package wpad-basic-mbedtls wants to install file /build/openwrt-imagebuilder-23.05.2-mediatek-mt7622.Linux-x86_64/build_dir/target-aarch64_cortex-a53_musl/root-mediatek/usr/sbin/wpad
> But that file is already provided by package * wpad-wolfssl
> * check_data_file_clashes: Package wpad-basic-mbedtls wants to install file /build/openwrt-imagebuilder-23.05.2-mediatek-mt7622.Linux-x86_64/build_dir/target-aarch64_cortex-a53_musl/root-mediatek/usr/share/hostap/hostapd.uc
> But that file is already provided by package * wpad-wolfssl
> * check_data_file_clashes: Package wpad-basic-mbedtls wants to install file /build/openwrt-imagebuilder-23.05.2-mediatek-mt7622.Linux-x86_64/build_dir/target-aarch64_cortex-a53_musl/root-mediatek/usr/share/hostap/wpa_supplicant.uc
> But that file is already provided by package * wpad-wolfssl
> * opkg_install_cmd: Cannot install package wpad-basic-mbedtls.
I've followed the instructions in the README to remove wpad-basic-wolfssl
. I can't find an authoritative reference, but it sounds like perhaps openwrt has replaced wpad-basic-wolfssl
with wpad-basic-mbedtls
(refs: https://www.reddit.com/r/openwrt/comments/12fqixx/out_of_curiosity_whats_the_difference_between_the/)?
A breaking change was introduced in Home Assistant 2023.8 involving naming of MQTT entities.
The following warning is logged by Home Assistant:
2023-08-03 10:52:24.376 WARNING (MainThread) [homeassistant.components.mqtt.mixins] MQTT entity name starts with the device name in your config {'availability_topic': 'wifi/access-point-4/status', 'device': {'connections': [['mac', '00:00:00:00:00:0']], 'name': 'Xiaomi Redmi K20', 'via_device': 'access-point-4', 'identifiers': []}, 'icon': 'mdi:wifi-marker', 'json_attributes_topic': 'wifi/station/access-point-4/00-00-00-00-00-00/attrs', 'name': 'Xiaomi Redmi K20 access-point-4', 'object_id': '000000000000_access-point-4', 'payload_available': 'online', 'payload_home': 'connected', 'payload_not_available': 'offline', 'payload_not_home': 'not_connected', 'qos': 2, 'source_type': 'router', 'state_topic': 'wifi/station/access-point-4/00-00-00-00-00-00/state', 'unique_id': 'wifipresence_000000000000_access-point-4', 'encoding': 'utf-8', 'enabled_by_default': True, 'payload_reset': 'None', 'availability_mode': 'latest'}, this is not expected. Please correct your configuration. The device name prefix will be stripped off the entity name and becomes 'Access-point-4'
Thanks for this integration, it looks very interesting.
How does it behave with clients roaming between multiple APs on the same network?
Have you considered integrating it with DAWN? This would allow users to roam around the house from AP to AP without false disconnect notifications.
It seems something is wrong. I can see the MAC of my devices, but the event is not recognized. I don't know if this is expected, but for some reason it does not publish nothing at my MQTT server, so maybe this is the culprit or maybe this is expected, I don't know:
Mon Apr 11 08:59:19 2022 daemon.notice hostapd: wlan5g: BEACON-REQ-TX-STATUS 58:cb:52:XX:XX:XX 119 ack=1
Mon Apr 11 08:59:19 2022 daemon.err wifi-presence[20175]: 2022/04/11 06:59:19 PIMINET: Event hostapd.EventUnrecognized: "<3>BEACON-REQ-TX-STATUS 58:cb:52:XX:XX:XX 119 ack=1"
Mon Apr 11 08:59:19 2022 daemon.err wifi-presence[20175]: 2022/04/11 06:59:19 PIMINET: event not handled hostapd.EventUnrecognized: "<3>BEACON-REQ-TX-STATUS 58:cb:52:XX:XX:XX 119 ack=1"
Mon Apr 11 08:59:20 2022 daemon.notice hostapd: wlan5g: BEACON-REQ-TX-STATUS f0:5c:77:XX:XX:XX 120 ack=1
Mon Apr 11 08:59:20 2022 daemon.err wifi-presence[20175]: 2022/04/11 06:59:20 PIMINET: Event hostapd.EventUnrecognized: "<3>BEACON-REQ-TX-STATUS f0:5c:77:XX:XX:XX 120 ack=1"
Mon Apr 11 08:59:20 2022 daemon.err wifi-presence[20175]: 2022/04/11 06:59:20 PIMINET: event not handled hostapd.EventUnrecognized: "<3>BEACON-REQ-TX-STATUS f0:5c:77:XX:XX:XX 120 ack=1"
Thanks!
Mon Sep 12 22:21:02 2022 daemon.err wifi-presence[3272]: Error: unable to connect to hostapd control socket "/var/run/hostapd/wlan0": ping error: read error from "PING" command: read unixgram /tmp/wp.wlan0->/var/run/hostapd/wlan0: i/o timeout
Hi, thanks for the integration - it was included in openwrt head today.
In order for it to work I needed to alter the init script to start it as the network user - it can't access the control interface otherwise.
Hi Adam,
I recently updated my APs to the latest OpenWrt master and have noted these new errors in the log:
root@openwrt-ap:~# logread | grep wifi-presence
Sat Nov 19 12:11:44 2022 daemon.err wifi-presence[4190]: Error: invalid MAC address "1a:xx:xx:xx:xx:xx auth_alg=open"
Sat Nov 19 12:31:51 2022 daemon.err wifi-presence[4282]: Error: invalid MAC address "34:xx:xx:xx:xx:xx auth_alg=open"
Sat Nov 19 13:07:59 2022 daemon.err wifi-presence[4390]: Error: invalid MAC address "34:xx:xx:xx:xx:xx auth_alg=open"
Sat Nov 19 13:10:03 2022 daemon.err wifi-presence[4573]: Error: invalid MAC address "60:xx:xx:xx:xx:xx auth_alg=ft"
Sat Nov 19 13:11:06 2022 daemon.err wifi-presence[4597]: Error: invalid MAC address "60:xx:xx:xx:xx:xx auth_alg=ft"
Sat Nov 19 13:20:16 2022 daemon.err wifi-presence[4608]: Error: invalid MAC address "60:xx:xx:xx:xx:xx auth_alg=ft"
Doing a bit of digging, I think the issue was introduced here: openwrt/openwrt@8cb9954
Could you take a look please? Happy to sponsor any package merge requests if needed.
Cheers,
Jon
Very promising project!
I installed wifi-presence_0.3.0-1_arm_cortex-a9_vfpv3-d16.ipk
on the latest 21.x version of OpenWRT:
DISTRIB_ID='OpenWrt'
DISTRIB_RELEASE='21.02.5'
DISTRIB_REVISION='r16688-fa9a932fdb'
DISTRIB_TARGET='mvebu/cortexa9'
DISTRIB_ARCH='arm_cortex-a9_vfpv3-d16'
DISTRIB_DESCRIPTION='OpenWrt 21.02.5 r16688-fa9a932fdb'
DISTRIB_TAINTS=''
When trying to start wifi-presence, I get these errors:
daemon.err wifi-presence: Error relocating /usr/bin/wifi-presence: __nanosleep_time64: symbol not found
Is wifi-presence supposed to work on 21.02?
Thanks!
Hello there
I get this error in the logs when I start wifi-presence:
daemon.err wifi-presence[6693]: Error: unable to connect to hostapd control socket "/var/run/hostapd/wlan0": ping error: read error from "PING" command: read unixgram /tmp/wp.wlan0->/var/run/hostapd/wlan0: i/o timeout
srwxrwx--- 1 network network 0 Oct 23 17:45 global
srwxrwx--- 1 network network 0 Oct 23 17:45 wlan0
srwxrwx--- 1 network network 0 Oct 23 17:45 wlan1
When I tried to install this tool as explained in https://github.com/awilliams/wifi-presence#opkg it installed a very old version (0.1.1), while the latest one is 0.3.0.
For now I can manually install the new version, but would be cool if the opkg repo was updated!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.