Skip to content

Instantly share code, notes, and snippets.

@e-minguez
Last active October 23, 2017 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e-minguez/28c9c48d6bcad29efb4a2160f85bcf10 to your computer and use it in GitHub Desktop.
Save e-minguez/28c9c48d6bcad29efb4a2160f85bcf10 to your computer and use it in GitHub Desktop.
Home Assistant dashbutton hostapd script
#!/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