A little bit of searching shows that a few people have made meeting indicators, some of which would have partially have worked for me in my situation.
The goal was to have an indicator (lamp) come on outside the door to my work area (office / study etc.) whereby someone (kids) would know not to disturb me at that time.
Due to the nature of my job, I have the freedom to install software onto my work laptop, and therefore this was a fairly simple task of using hass workstation service, mosquitto (already installed) an automation, and a multi-coloured zigbee LED in an ikea standing lamp. I can provide the yaml if anyone cares, but this was not a particularly novel bit of code.
The more novel bit was how I got this to work on my wife’s laptop, where I can’t install software. In this case she only uses Microsoft Teams for work, so my solution was to find out what ports Teams uses when a call is active, then run a script on my router to check for those and curl the HA rest API when it changes.
This only works because my router is running a Linux (Ubiquiti Edgemax). I imagine you could do something similar with other routers where you have a cli (or a good network API), but that’s an exercise for the reader. Also NB I’m not a software engineer, so this codes probably sucks, but it works for me so YMMV.
The script that runs on the router:
#!/bin/bash
set -u
set -o pipefail
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
function set_server_state() {
target_state=$1
set -x
curl -s -X POST -H "Authorization: Bearer ###mybearertoken###" \
-H "Content-Type: application/json" \
-d "{\"state\":\"${target_state}\"}" \
http://<haip>:8123/api/states/input_boolean.wife_on_call
set +x
}
teamscallconnections=0
wife_on_call="false"
wife_on_call_old="false"
while [[ 1 ]]
do
wife_on_call_old=$wife_on_call
teamscallconnections=$(conntrack -L -s <wifeslaptopip> -p udp 2>/dev/null \
| grep <wifeslaptopip> | awk '{print $3, $5, $6, $7}' \
| grep -e 'sport=500[0-9][0-9] dport=3478\|3479\|3480\|3481' \
| awk '$1>95{print}' | wc -l)
if [[ teamscallconnections -gt 0 ]] ; then
wife_on_call="true"
else
wife_on_call="false"
fi
#echo -n "wife_on_call: $wife_on_call, "
if [[ $wife_on_call != $wife_on_call_old ]] ; then
if [[ $wife_on_call == "true" ]] ; then
set_server_state "on"
#echo "set on"
sleep 20 # to avoid spamming the HA server
else
set_server_state "off"
#echo "set off"
sleep 20 # to avoid spamming the HA server
fi
else
#echo "no change"
/bin/true
fi
sleep 5
done