Skip to main content

Detects if the user is an online call, publishes gathered information to an MQTT broker

Project description

call_detector

call_detector listens to microphone and camera states to detect if the user is participating in an online call. Gathered information is being published to an MQTT broker.

Where it works

Currently only Linux is supported, I don't have plans to support other operating systems. If you're interested, feel free to open a PR.

In order to use call_detector you'll need pulseaudio or pipewire-pulse and libpulse.

How it works

call_detector listens to pulseadio events to detect apps which use the microphone and uses inotify with some /proc magic to find apps which use the camera.

MQTT

call_detector was only tested against mosquitto MQTT broker with login/password authentication and TLS enabled, however in therory it can work without TLS and authentication and against any broker supported by gmqtt.

Every time the call_detector detects an app which starts or stops using the microphone or the camera, it publishes a message to an MQTT topic with name of the format call_detector/<hostname> where hostname is the hostname of the machine where you run call_detector. Also it sends a message on start and every minute.

Message examples:

{"camera": [], "microphone": [], "call": false} when camera and microphone are not active.

{"camera": ["firefox"], "microphone": ["firefox"], "call": true} when user is in an online call using firefox.

Installation

pip install call_detector

Usage

Basic usage:

call_detector -H mqtt.example.com -U user -P password

More advanced options can be found in help

call_detector --help

Home Assistant

Binary sensor:

binary_sensor:
  - platform: mqtt
    name: "User in an online meeting"
    state_topic: "call_detector/<hostname>" # check call_detector --help to find the default topic for your computer
    value_template: "{{ 'ON' if value_json.call else 'OFF' }}"
    json_attributes_topic: "call_detector/<hostname>" # same as state_topic
    json_attributes_template: "{{ value_json | tojson }}"
    qos: 1

Automation example:

- alias: Pause music while User is in an online meting
  trigger:
    - platform: state
      entity_id: binary_sensor.user_in_an_online_meeting
      to: "on"

  condition:
    - condition: state
      entity_id: media_player.mpd
      state: "playing"

  action:
    - service: media_player.media_pause
      data:
        entity_id: media_player.mpd

    - wait_for_trigger:
        - platform: state
          entity_id: binary_sensor.user_in_an_online_meeting
          to: "off"

    - service: media_player.media_play
      data:
        entity_id: media_player.mpd

Contribution

You know;)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

call_detector-0.2.4.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

call_detector-0.2.4-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file call_detector-0.2.4.tar.gz.

File metadata

  • Download URL: call_detector-0.2.4.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for call_detector-0.2.4.tar.gz
Algorithm Hash digest
SHA256 5ed43acf510f14a343f0d6336237631ca3d5cdafb4291a4858649ca53cdfb2b5
MD5 d4a3cd6979868a6db42144ebc4e867b4
BLAKE2b-256 5b08b036ccbcdbcf67123c0d0f9d46da9b0c4905a8c29fce79c03be96f74f65e

See more details on using hashes here.

File details

Details for the file call_detector-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: call_detector-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for call_detector-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 dbf4240b7fbd5a67ce4b80749bee6c48b5454bd0ea353a422321825e30bbd9e3
MD5 d706ef05a73beb4e7748b7ad645fe813
BLAKE2b-256 937db778a4d93b04a70437719ea4e20426d8280d5ed1faaf1d1c71990eaff121

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page