In a meeting sensor, without agent software on the laptop

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

So here is what I do, I have the home assistant app on my laptop anyways.

I watch the camera in use status and if it’s in use I trigger a scene.

I use this light coupled with a zigbee rgb led strip controller.

Led Signal Lights Industrial Warning Lights Emergency Lamp Beacon Indicator Steady Continuous Light 24VDC 3 Colors Single Layer Three Tower Light Waterproof (Flat Type, No Buzzer, Plastic) https://www.amazon.com/dp/B098BGH5N4/ref=cm_sw_r_cp_api_i_P19BAAQEAMZM1YC7ZWXA?_encoding=UTF8&psc=1

The way the rgb controller works is it will pass a certain percentage of voltage to represent a Color When I make it pure red/green I get 12v on each specific contact and the light has a positive wire for each if that makes sense.

Mostly I use my light for red/green/off.

I also run a iOS shortcut on my cell phone when it’s in use to update an automation to also turn on the light if I take a phone call.

The port function you came up with is slick though, very good thinking.