GithubHelp home page GithubHelp logo

call_detector's Introduction

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;)

call_detector's People

Contributors

volfyd avatar zhulik avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

volfyd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.