Last active
October 23, 2017 12:36
-
-
Save e-minguez/28c9c48d6bcad29efb4a2160f85bcf10 to your computer and use it in GitHub Desktop.
Home Assistant dashbutton hostapd script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Use it with /usr/sbin/hostapd_cli -i wlan1 -a /root/hostapd/notify.sh -B | |
HASS="http://192.168.1.2:8123" | |
SCOTTEX="xx:xx:xx:xx:xx:xx" | |
FAIRY="yy:yy:yy:yy:yy:yy" | |
CURL="/usr/bin/curl -s" | |
MAC=$3 | |
if [[ $2 == "AP-STA-CONNECTED" ]] | |
then | |
case "$MAC" in | |
"$FAIRY") | |
EVENT="fairy" | |
;; | |
"$SCOTTEX") | |
EVENT="scottex" | |
;; | |
*) | |
exit 0 | |
;; | |
esac | |
# echo "$Evento: $EVENT, MAC: $3, Status: $2" | |
$CURL -X POST -H "Content-Type: application/json" $HASS/api/events/${EVENT} > /dev/null | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment