RTC Call Monitor - Add active voice/video call status to HA

I’ve been wanting to add an automatic ‘On a call’ light outside my office so that my kids know not to come into my office during work calls. A manual light would suffice, but I wanted to automatically turn on when I start a call. An added complication for me is that I use Slack, Zoom and Google Meet for calls, which makes automation a bit tricky.

I finally decided to tackle this automation and built RTC-Call-Monitor . It has been reliably detecting the start and end of any call on my machine that uses UDP.

RTC Call Monitor isn’t a HA Integration since it needs to run on the same machine that you use to make voice/video calls. The application will call a webhook at the start and end of a call, which works great with HA Webhook Triggers.

Currently the application can only be run via the command line, but I’ll be adding support for installing as a Windows service in a few days.

Feedback and suggestions are welcome!

2 Likes

Plan on taking a look at this hopefully tomorrow, thanks. Can this pull a notification when the “phone” is ringing? Specifically from Teams?

It depends on how MS Teams tells the client app that there is an incoming call. Slack sends a burst of UDP packets when an incoming call is ringing. Hopefully Teams will work in a similar manner.

You mean there is no API to tell you when a call is coming?

RTC Call Monitor v1.0.0 has been released. This version has the option to install as a Windows service.

To install:

  • Extract the archive
  • Follow the instructions in the readme to modify appsettings.json for your local network
  • Run RTCCallMonitor.exe from a console with admin privileges to ensure that your local network is correctly configured.
  • Optionally run install.ps1 to install as a Windows service.

Hi Eric, I’d like to try the app but I’m a little stuck. Can you help?

  • You are refering to the readme, but there’s no readme included in v1.0.0-win.zip. I am now checking out the readme on Github.
  • I am assuming I need to configure a webhook, but can’t find the instructions for that. What do I enter for CallStartWebhook and CallEndWebhook ?

Curious how we tie this into HA. I have the service running and it sees my calls from different calling applications but all my logic and automation is in HA. Would you be able to add mqtt connectivity and have the ability to update busy status (available, busy, etc) and activity status (in a call)?

I figured out how to get this working VERY reliably. First off THANK YOU @ericgla for writing a service that works for all web meeting/conference software. THIS is awesome! For those who are beginners attempting to get this going do the following:

Setup HA Requirements:

  1. HACS: Install Virtual Components
  2. Add to your configuration.yaml file/switches section add:
    • platform: virtual
      name: On a Call
  3. Go to Configuration/Automations
  4. Add a new Automation
    Name: Call Start
    Mode: Single
    Trigger Type: Webhook
    Webhook ID: callstart
    Actions type: Call Service
    Service: switch.turn_on
    Target Entity: switch.virtual_on_a_call
  5. Save and go back to Automations
  6. Add a new Automation
    Name: Call Stop
    Mode: Single
    Trigger Type: Webhook
    Webhook ID: callstop
    Actions type: Call Service
    Service: switch.turn_off
    Target Entity: switch.virtual_on_a_call
  7. Save and go to Configuration/Server Controls and restart HA

Setup RTC Monitor on your PC:

  1. Download the windows.zip file from the GitHub and unzip into a folder (example C:\Scripts)
  2. Run an elevated Powershell
  3. Navigate to your directory
  4. Execute: Unblock-File .\install.ps1
  5. Execute: .\install.ps1
  6. Edit appsettings.json
  7. Modify the “LocalNetwork” to represent your network and subnet space
  8. Modify the “CallStartWebhook” with http://[your_HA_ip_address]:8123/api/webhook/callstart
  9. Modify the “CallEndWebhook” with http://[your_HA_ip_address]:8123/api/webhook/callstop
  10. Save and Exit
  11. Start services.msc
  12. Start the RTC Monitor Service

Make a call and watch in your developer tools in HA the switch turn on/off. :slight_smile:

@PrayerfulDrop, curious as to why you need the custom component in steps 1 and 2. Why not use one of the helpers like an input boolean? I couldn’t find the component in HACS as well, so I’m not sure if there is something special that it provides. Let me know. Thanks.

Great to hear it’s working well for you. I’ve been using it for about a month now and it’s been completely reliable, and my kids now know to look at my LIFX panels to see if daddy is on a call…

FYI - I’m also using an input boolean as mentioned by @stephack

I am not a fan of the input Boolean. Idk why but some automations in NR don’t seem to work as expected. So I use a virtual component. Maybe it is from the Hubitat days?

Anyways, the above directions at least help the new ppl looking to do this. :grin:

I hear ya. Wasn’t a fan of it initially as well. Virtual Device creation is a lot better with a lot of options and dwvixe types in HE.
Kinda why I’m curious about this component. I wasn’t able to find it in HACS, so I dug around the forum and found a post pointing to this. Is this is what you were referring to?

Yes that is what I am using. Installed through HACS.

I know this one is a bit late, but does anyone using this tool see a weird issue where a call will basically start and stop a number of times, tripping up the automation? I also posted an issue in the GitHub, but wanted to ask here. Essentially, a single call (example here, Discord) will show as start/stop/start/stop/start/stop which keeps triggering automations.

image

I have not seen any issues with it. I have it turning on a virtual switch that triggers lighting automations. No issues yet.

I built it from source (which is several commits newer than the 1.0.0 release zip) and it appears to work much better.

Thanks @ericgla this is brilliant. Its working fine on my work computers to show current status. I’m using an automation to control an input boolean which is fine.

I’m wondering if you can help with using the POST body provider data - I thought it’d be good to include the provider in a template binary sensor attribute but I’m a bit lost on how to do this!

Here’s how to set up a template binary sensor including attributes:

template:
  - trigger:
    - platform: webhook
      webhook_id: my_secretID
    binary_sensor:
      - name: "Videocall"
        state: "{{ 'provider' in trigger.json }}"
        attributes:
          provider: "{{trigger.json.provider}}"
          duration: "{{trigger.json.duration}}"

Explanation:
In the application settings you need to specify the same webhook for both events.
The sensor checks, when triggered by the webhook, if it is a start message (which includes the key ‘provider’) and respons with an on-state. You only get values for one of the two attributes, depending on the last message from the service.

1 Like

Thanks so much, I really like this - it also cuts down on the input_boolean and automation I had to handle the status before. Always like when I can make these things simpler, AND I now get these extra attributes!

Not quite sure what I’ll do with them, might use duration to log how much time I spend (or waste?!) on calls a week…

Cheers

Did anyone get this running under Ubuntu(20.04)?
I’m getting the following ill-formatted error message:

<3>RtcCallMonitor.Worker[0] System.PlatformNotSupportedException: Socket.IOControl handles Windows-specific control codes and is not supported on this platform. at System.Net.Sockets.SocketPal.WindowsIoctl(SafeSocketHandle handle, Int32 ioControlCode, Byte[] optionInValue, Byte[] optionOutValue, Int32& optionLength) at System.Net.Sockets.Socket.IOControl(Int32 ioControlCode, Byte[] optionInValue, Byte[] optionOutValue) at RtcCallMonitor.NetworkListener.CreateAndBindSocket() in /home//RTC-Call-Monitor/src/NetworkListener.cs:line 39 at RtcCallMonitor.NetworkListener.Start() in /home//RTC-Call-Monitor/src/NetworkListener.cs:line 59 at RtcCallMonitor.NetworkListener.UpdateIpAddress(IPAddress newAddress) in /home//RTC-Call-Monitor/src/NetworkListener.cs:line 71 at RtcCallMonitor.TrafficMonitor.NetworkChange_NetworkAddressChanged(Object sender, EventArgs e) in /home//RTC-Call-Monitor/src/TrafficMonitor.cs:line 116 at RtcCallMonitor.TrafficMonitor.Start() in /home//RTC-Call-Monitor/src/TrafficMonitor.cs:line 79 at RtcCallMonitor.Worker.ExecuteAsync(CancellationToken stoppingToken) in /home//RTC-Call-Monitor/src/Worker.cs:line 29