# ringr
[![Build Status](https://github.com/albertoalcolea/ringr/workflows/Tests/badge.svg)](https://github.com/albertoalcolea/ringr/actions?query=workflow%3ATests)
[![Latest PyPI Version](https://img.shields.io/pypi/v/ringr.svg)](https://pypi.python.org/pypi/ringr)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/ringr.svg)](https://pypi.python.org/pypi/ringr)
Sound event detection system based on the open-source cross-platform PortAudio API.
It supports multiple notification backends, and it has been designed to run on low-specs and inexpensive hardware like the lowest range of raspberry products (RPi 1, RPi Zero, RPi Zero 2, etc).
## Use cases
Some interesting use cases where to use *ringr* to automate your smart home and help disabled people:
* Intercom and doorbell detection
* Detection of the end-of-program audible warning of some appliances such as washing machines, clothes dryers or dishwashers
* Baby crying detection
* Dog bark detection
## Design considerations and constraints
This has born as a personal project for a very concrete use case that can be extrapolated to multiple other contexts and needs.
Some of my personal requirements and constraints include:
* It must run on an old Raspberry Pi 1 that I have stored in a drawer and unused for some many years to give it a new life.
* It must run with very cheap and low quality microphones.
* It must be able to detect the intercom and doorbell notification sounds without false positives warnings.
* It must notify states to my personal Home Assistant installation and provide support to add more notification backends in the future.
More information about the concept and design of *ringr* in [this post on my personal blog](https://albertoalcolea.com/blog/ringr-a-sound-event-detection-system/).
## Installation
On all systems, install *ringr* by using `pip`:
```
pip install ringr
```
### Systemd
Copy the file `ringr.service` available in this repository to `/etc/systemd/system/ringr.service`
Edit the service and modify the application path, the user and the group if needed.
Reload the systemd daemon to load the new service by executing `systemctl daemon-reload`.
Start the service with `systemctl start ringr.service` and enable it if you want to run it automatically at startup: `systemctl enable ringr.service`
### Docker
Alternatively to a native installation you can use Docker.
A Dockerfile is provided to build a Docker image for *ringr*.
```
docker build -t ringr .
```
No volumes are needed as *ringr* is a stateless service.
Remember you need to add the host sound device to your container with `--device`
```
docker run -d \
--name=ringr \
--device=/dev/snd:/dev/snd
-e TZ=Europe/Madrid \
-e PUID=1000 \
-e GUID=1000 \
-e RINGR_DETECTOR_DEVICE='1' \
-e RINGR_DETECTOR_THRESHOLD='65' \
-e RINGR_DETECTOR_PEAK_DURATION='0.8' \
-e RINGR_DETECTOR_FREQUENCY='1000' \
-e RINGR_DETECTOR_ACCEPTANCE_RATIO='90' \
-e RINGR_DETECTOR_GAIN='200' \
-e RINGR_DETECTOR_LATENCY='0.1' \
-e RINGR_DETECTOR_COOLDOWN='15' \
-e RINGR_NOTIFIER_TYPE='ha' \
-e RINGR_NOTIFIER_MQTT_HOST='10.10.0.50' \
-e RINGR_NOTIFIER_USER='ringr' \
-e RINGR_NOTIFIER_PASS='secret' \
--restart unless-stopped \
ringr:latest
```
#### docker-compose
Example of a *docker-compose* file:
```
version: '3'
services:
ringr:
container_name: ringr
image: ringr:latest
devices:
- '/dev/snd:/dev/snd'
environment:
TZ: 'Europe/Madrid'
PUID: '1000'
GUID: '1000'
RINGR_DETECTOR_DEVICE: '1'
RINGR_DETECTOR_THRESHOLD: '65'
RINGR_DETECTOR_PEAK_DURATION: '0.8'
RINGR_DETECTOR_FREQUENCY: '1000'
RINGR_DETECTOR_ACCEPTANCE_RATIO: '90'
RINGR_DETECTOR_GAIN: '200'
RINGR_DETECTOR_LATENCY: '0.1'
RINGR_DETECTOR_COOLDOWN: '15'
RINGR_NOTIFIER_TYPE: 'ha'
RINGR_NOTIFIER_MQTT_HOST: '10.10.0.50'
RINGR_NOTIFIER_USER: 'ringr'
RINGR_NOTIFIER_PASS: 'secret'
restart: unless-stopped
```
## Usage
Use the `ringr` command to launch the application.
It supports the following optional parameters:
* `-c`, `--conf`: configuration file. By default it uses `/etc/ringr/ringr.conf`
* `-v`, `--verbose`: configure the log level of the logger in debug level
## Configuration
*ringr* can be configured through a configuration file or with environment variables, useful if you run it within a docker container.
The expected path to the configuration file is `/etc/ringr/ringr.conf`.
### Detector
The configuration of the detector is defined inside the `[detector]` section of the configuration files.
It supports the following options:
#### device
| Option | Environment variable | Data type | Unit | Default |
| --- | --- | --- | --- | --- |
| `device` | `RINGR_DETECTOR_DEVICE` | integer | | |
Index of the input sound device.
You can get the list of PortAudio sound devices and their index with the following command:
```
$ python -m sounddevice
0 sof-hda-dsp: - (hw:1,0), ALSA (2 in, 2 out)
1 sof-hda-dsp: - (hw:1,4), ALSA (0 in, 2 out)
2 sof-hda-dsp: - (hw:1,5), ALSA (0 in, 2 out)
3 sof-hda-dsp: - (hw:1,6), ALSA (2 in, 0 out)
4 sof-hda-dsp: - (hw:1,7), ALSA (2 in, 0 out)
5 pulse, ALSA (32 in, 32 out)
* 6 default, ALSA (32 in, 32 out)
```
#### threshold
| Option | Environment variable | Data type | Unit | Default |
| --- | --- |-----------|------| --- |
| `threshold` | `RINGR_DETECTOR_THRESHOLD` | float | % | |
Relative amplitude threshold for the event detection. It must be a value in the range [0,100].
#### peak_duration
| Option | Environment variable | Data type | Unit | Default |
| --- | --- |-----------|-------| --- |
| `peak_duration` | `RINGR_DETECTOR_PEAK_DURATION` | float | secs. | |
Duration of the signal over the threshold amplitude before to be considered an event.
#### frequency
| Option | Environment variable | Data type | Unit | Default |
|-------------|----------------------------|-----------|---| --- |
| `frequency` | `RINGR_DETECTOR_FREQUENCY` | int | Hz | |
Frequency where to analyze the event.
The event will be analyzed inside a frequency range where the highest frequency will be the closest possible frequency to the desired frequency based on the number of frequency bins used.
#### frequency_bins
| Option | Environment variable | Data type | Unit | Default |
|------------------|---------------------------------|-----------|-|---------|
| `frequency_bins` | `RINGR_DETECTOR_FREQUENCY_BINS` | int | | 256 |
Number of frequency bins in which divide the range of audible frequencies.
The detector will analyze the frequency bin whose highest frequency is closest to the desired frequency.
For example, with `frequency = 1000` and `frequency_bins` = 256, the detector will analyze the range between 951 Hz and 1037 Hz.
#### acceptance_ratio
| Option | Environment variable | Data type | Unit | Default |
|------------------|-----------------------------------|-----------|------|---------|
| `acceptance_ratio` | `RINGR_DETECTOR_ACCEPTANCE_RATIO` | float | % | 100 |
Number of samples that must be above the amplitude threshold in the desired frequency range during the `peak_duration` time.
#### gain
| Option | Environment variable | Data type | Unit | Default |
|--------|-----------------------|-----------|------|--------|
| `gain` | `RINGR_DETECTOR_GAIN` | int | | 0 |
Some input devices may capture very low signals. Use this parameter to boost them to have more control on its amplitude.
#### latency
| Option | Environment variable | Data type | Unit | Default |
|-----------|--------------------------|-----------|-------|---------|
| `latency` | `RINGR_DETECTOR_LATENCY` | float | secs. | *high* |
Input latency of capture.
Higher values will prevent input overflow errors that will discard samples and produce more robust and predictable results.
By default, it will use the predefined high input latency of your input sound device.
You can query that value using the following command replacing the argument in the `query_devices` method by the device index of your device:
```
$ python -c 'import sounddevice as sd; print(sd.query_devices(1))'
{'name': 'default', 'index': 11, 'hostapi': 0, 'max_input_channels': 32, 'max_output_channels': 32, 'default_low_input_latency': 0.008684807256235827, 'default_low_output_latency': 0.008684807256235827, 'default_high_input_latency': 0.034807256235827665, 'default_high_output_latency': 0.034807256235827665, 'default_samplerate': 44100.0}
```
#### cooldown
| Option | Environment variable | Data type | Unit | Default |
|------------|---------------------------|-----------|-------|---------|
| `cooldown` | `RINGR_DETECTOR_COOLDOWN` | float | secs. | 10 |
Cooldown time in seconds after a detection. Any sample during this period will be discarded and will not be analyzed.
#### block_duration
| Option | Environment variable | Data type | Unit | Default |
|-----------|--------------------------------|-----------|------------|---------|
| `block_duration` | `RINGR_DETECTOR_BLOCK_DURATION` | float | millisecs. | 50 |
Duration of the sample to analyze.
Higher values may provoke input overflow errors.
#### log_analysis
| Option | Environment variable | Data type | Unit | Default |
|----------------|-------------------------------|-----------|------------|---------|
| `log_analysis` | `RINGR_DETECTOR_LOG_ANALYSIS` | bool | | False |
Verbose output of analysis. Use with log level = debug
### Notification backends
The configuration of the chosen notification backend is defined inside the `[notifier]` section of the configuration file.
All notification backends share one option: `type` which specifies the notification backend to use. The corresponding environment variable for this option is `RINGR_NOTIFIER_TYPE`
Available notification backends:
| Name | Type | Description |
| --- | --- | --- |
| Home Assistant | `ha` | Auto-discoverable MQTT device for Home Assistant |
| Telegram | `telegram` | Telegram Bot |
#### Home Assistant
Use `type: ha`
| Option | Environment variable | Data type | Default | Description |
|-------------|------------------------------|-----------|------------|-------------------------------------------------------------------------------------------------------------------------|
| `device_id` | `RINGR_NOTIFIER_DEVICE_ID` | str | ringr_01 | Unique device id. Override this value if you run multiple instances of *ringr* |
| `device_name` | `RINGR_NOTIFIER_DEVICE_NAME` | str | ringr 01 | Device name. Override this value if you run multiple instances of *ringr* or to use a custom name within Home Assistant |
| `mqtt_host` | `RINGR_NOTIFIER_MQTT_HOST` | str | | Host of the MQTT broker |
| `mqtt_port` | `RINGR_NOTIFIER_MQTT_PORT` | int | 1883 | Port of the MQTT broker |
| `mqtt_user` | `RINGR_NOTIFIER_MQTT_USER` | str | | Optional username to authenticate with the MQTT broker. Use it together with `mqtt_pass` |
| `mqtt_pass` | `RINGR_NOTIFIER_MQTT_PASS` | str | | Optional password to authenticate with the MQTT broker. Use it together with `mqtt_user` |
| `mqtt_client_id` | `RINGR_NOTIFIER_MQTT_CLIENT_ID` | str | `ringr_01` | Client id of the MQTT client. Override this value if you run multiple instances of *ringr* |
| `mqtt_qos` | `RINGR_NOTIFIER_MQTT_QOS` | int | 1 | MQTT QoS of published messages |
#### Telegram
Use `type: telegram`
| Option | Environment variable | Data type | Default | Description |
|-------------|------------------------------|-----------|------------|---|
| `api_token` | `RINGR_NOTIFIER_API_TOKEN` | str | | Telegram Bot API Token |
| `chat_id` | `RINGR_NOTIFIER_CHAT_ID` | str | | Telegram Chat ID |
| `message` | `RINGR_NOTIFIER_MESSAGE` | str | Event detected | Message to send where an event is detected |
### Full example
Configuration file:
```python
[detector]
device: 1
threshold: 65
peak_duration: 0.8
frequency: 1000
acceptance_ratio: 90
gain: 200
latency: 0.1
cooldown: 15
[notifier]
type: ha
mqtt_host: 10.10.0.50
mqtt_user: ringr
mqtt_pass: secret
```
Or, by using environment variables:
```bash
RINGR_DETECTOR_DEVICE='1'
RINGR_DETECTOR_THRESHOLD='65'
RINGR_DETECTOR_PEAK_DURATION='0.8'
RINGR_DETECTOR_FREQUENCY='1000'
RINGR_DETECTOR_ACCEPTANCE_RATIO='90'
RINGR_DETECTOR_GAIN='200'
RINGR_DETECTOR_LATENCY='0.1'
RINGR_DETECTOR_COOLDOWN='15'
RINGR_NOTIFIER_TYPE='ha'
RINGR_NOTIFIER_MQTT_HOST='10.10.0.50'
RINGR_NOTIFIER_USER='ringr'
RINGR_NOTIFIER_PASS='secret'
```
Raw data
{
"_id": null,
"home_page": "https://github.com/albertoalcolea/ringr",
"name": "ringr",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "ringr, ring, sound, sound detection, audio, audio detection, frequency analyzer, peak detection, home assistant",
"author": "Alberto Alcolea",
"author_email": "albertoalcolea@gmail.com",
"download_url": null,
"platform": null,
"description": "# ringr\n\n[![Build Status](https://github.com/albertoalcolea/ringr/workflows/Tests/badge.svg)](https://github.com/albertoalcolea/ringr/actions?query=workflow%3ATests)\n[![Latest PyPI Version](https://img.shields.io/pypi/v/ringr.svg)](https://pypi.python.org/pypi/ringr)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/ringr.svg)](https://pypi.python.org/pypi/ringr)\n\nSound event detection system based on the open-source cross-platform PortAudio API.\n\nIt supports multiple notification backends, and it has been designed to run on low-specs and inexpensive hardware like the lowest range of raspberry products (RPi 1, RPi Zero, RPi Zero 2, etc).\n\n## Use cases\n\nSome interesting use cases where to use *ringr* to automate your smart home and help disabled people:\n* Intercom and doorbell detection\n* Detection of the end-of-program audible warning of some appliances such as washing machines, clothes dryers or dishwashers\n* Baby crying detection\n* Dog bark detection\n\n## Design considerations and constraints\n\nThis has born as a personal project for a very concrete use case that can be extrapolated to multiple other contexts and needs.\n\nSome of my personal requirements and constraints include:\n* It must run on an old Raspberry Pi 1 that I have stored in a drawer and unused for some many years to give it a new life.\n* It must run with very cheap and low quality microphones.\n* It must be able to detect the intercom and doorbell notification sounds without false positives warnings.\n* It must notify states to my personal Home Assistant installation and provide support to add more notification backends in the future.\n\nMore information about the concept and design of *ringr* in [this post on my personal blog](https://albertoalcolea.com/blog/ringr-a-sound-event-detection-system/).\n\n## Installation\n\nOn all systems, install *ringr* by using `pip`:\n\n```\npip install ringr\n```\n\n### Systemd\n\nCopy the file `ringr.service` available in this repository to `/etc/systemd/system/ringr.service`\n\nEdit the service and modify the application path, the user and the group if needed.\n\nReload the systemd daemon to load the new service by executing `systemctl daemon-reload`.\n\nStart the service with `systemctl start ringr.service` and enable it if you want to run it automatically at startup: `systemctl enable ringr.service`\n\n### Docker\n\nAlternatively to a native installation you can use Docker.\n\nA Dockerfile is provided to build a Docker image for *ringr*.\n\n```\ndocker build -t ringr .\n```\n\nNo volumes are needed as *ringr* is a stateless service.\n\nRemember you need to add the host sound device to your container with `--device`\n\n```\ndocker run -d \\\n --name=ringr \\\n --device=/dev/snd:/dev/snd\n -e TZ=Europe/Madrid \\\n -e PUID=1000 \\\n -e GUID=1000 \\\n -e RINGR_DETECTOR_DEVICE='1' \\\n -e RINGR_DETECTOR_THRESHOLD='65' \\\n -e RINGR_DETECTOR_PEAK_DURATION='0.8' \\\n -e RINGR_DETECTOR_FREQUENCY='1000' \\\n -e RINGR_DETECTOR_ACCEPTANCE_RATIO='90' \\\n -e RINGR_DETECTOR_GAIN='200' \\\n -e RINGR_DETECTOR_LATENCY='0.1' \\\n -e RINGR_DETECTOR_COOLDOWN='15' \\\n -e RINGR_NOTIFIER_TYPE='ha' \\\n -e RINGR_NOTIFIER_MQTT_HOST='10.10.0.50' \\\n -e RINGR_NOTIFIER_USER='ringr' \\\n -e RINGR_NOTIFIER_PASS='secret' \\\n --restart unless-stopped \\\n ringr:latest\n```\n\n#### docker-compose\n\nExample of a *docker-compose* file:\n\n```\nversion: '3'\nservices:\n ringr:\n container_name: ringr\n image: ringr:latest\n devices:\n - '/dev/snd:/dev/snd'\n environment:\n TZ: 'Europe/Madrid'\n PUID: '1000'\n GUID: '1000'\n RINGR_DETECTOR_DEVICE: '1'\n RINGR_DETECTOR_THRESHOLD: '65'\n RINGR_DETECTOR_PEAK_DURATION: '0.8'\n RINGR_DETECTOR_FREQUENCY: '1000'\n RINGR_DETECTOR_ACCEPTANCE_RATIO: '90'\n RINGR_DETECTOR_GAIN: '200'\n RINGR_DETECTOR_LATENCY: '0.1'\n RINGR_DETECTOR_COOLDOWN: '15'\n RINGR_NOTIFIER_TYPE: 'ha'\n RINGR_NOTIFIER_MQTT_HOST: '10.10.0.50'\n RINGR_NOTIFIER_USER: 'ringr'\n RINGR_NOTIFIER_PASS: 'secret'\n restart: unless-stopped\n```\n\n## Usage\n\nUse the `ringr` command to launch the application.\n\nIt supports the following optional parameters:\n* `-c`, `--conf`: configuration file. By default it uses `/etc/ringr/ringr.conf`\n* `-v`, `--verbose`: configure the log level of the logger in debug level\n\n## Configuration\n\n*ringr* can be configured through a configuration file or with environment variables, useful if you run it within a docker container.\n\nThe expected path to the configuration file is `/etc/ringr/ringr.conf`.\n\n### Detector\n\nThe configuration of the detector is defined inside the `[detector]` section of the configuration files.\n\nIt supports the following options:\n\n#### device\n\n| Option | Environment variable | Data type | Unit | Default |\n| --- | --- | --- | --- | --- |\n| `device` | `RINGR_DETECTOR_DEVICE` | integer | | |\n\nIndex of the input sound device.\n\nYou can get the list of PortAudio sound devices and their index with the following command:\n\n```\n$ python -m sounddevice\n 0 sof-hda-dsp: - (hw:1,0), ALSA (2 in, 2 out)\n 1 sof-hda-dsp: - (hw:1,4), ALSA (0 in, 2 out)\n 2 sof-hda-dsp: - (hw:1,5), ALSA (0 in, 2 out)\n 3 sof-hda-dsp: - (hw:1,6), ALSA (2 in, 0 out)\n 4 sof-hda-dsp: - (hw:1,7), ALSA (2 in, 0 out)\n 5 pulse, ALSA (32 in, 32 out)\n* 6 default, ALSA (32 in, 32 out)\n```\n\n#### threshold\n\n| Option | Environment variable | Data type | Unit | Default |\n| --- | --- |-----------|------| --- |\n| `threshold` | `RINGR_DETECTOR_THRESHOLD` | float | % | |\n\nRelative amplitude threshold for the event detection. It must be a value in the range [0,100].\n\n#### peak_duration\n\n| Option | Environment variable | Data type | Unit | Default |\n| --- | --- |-----------|-------| --- |\n| `peak_duration` | `RINGR_DETECTOR_PEAK_DURATION` | float | secs. | |\n\nDuration of the signal over the threshold amplitude before to be considered an event.\n\n#### frequency\n\n| Option | Environment variable | Data type | Unit | Default |\n|-------------|----------------------------|-----------|---| --- |\n| `frequency` | `RINGR_DETECTOR_FREQUENCY` | int | Hz | |\n\nFrequency where to analyze the event.\n\nThe event will be analyzed inside a frequency range where the highest frequency will be the closest possible frequency to the desired frequency based on the number of frequency bins used.\n\n#### frequency_bins\n\n| Option | Environment variable | Data type | Unit | Default |\n|------------------|---------------------------------|-----------|-|---------|\n| `frequency_bins` | `RINGR_DETECTOR_FREQUENCY_BINS` | int | | 256 |\n\nNumber of frequency bins in which divide the range of audible frequencies.\n\nThe detector will analyze the frequency bin whose highest frequency is closest to the desired frequency.\n\nFor example, with `frequency = 1000` and `frequency_bins` = 256, the detector will analyze the range between 951 Hz and 1037 Hz.\n\n#### acceptance_ratio\n\n| Option | Environment variable | Data type | Unit | Default |\n|------------------|-----------------------------------|-----------|------|---------|\n| `acceptance_ratio` | `RINGR_DETECTOR_ACCEPTANCE_RATIO` | float | % | 100 |\n\nNumber of samples that must be above the amplitude threshold in the desired frequency range during the `peak_duration` time.\n\n#### gain\n\n| Option | Environment variable | Data type | Unit | Default |\n|--------|-----------------------|-----------|------|--------|\n| `gain` | `RINGR_DETECTOR_GAIN` | int | | 0 |\n\nSome input devices may capture very low signals. Use this parameter to boost them to have more control on its amplitude.\n\n#### latency\n\n| Option | Environment variable | Data type | Unit | Default |\n|-----------|--------------------------|-----------|-------|---------|\n| `latency` | `RINGR_DETECTOR_LATENCY` | float | secs. | *high* |\n\nInput latency of capture.\n\nHigher values will prevent input overflow errors that will discard samples and produce more robust and predictable results.\n\nBy default, it will use the predefined high input latency of your input sound device.\n\nYou can query that value using the following command replacing the argument in the `query_devices` method by the device index of your device:\n\n```\n$ python -c 'import sounddevice as sd; print(sd.query_devices(1))'\n{'name': 'default', 'index': 11, 'hostapi': 0, 'max_input_channels': 32, 'max_output_channels': 32, 'default_low_input_latency': 0.008684807256235827, 'default_low_output_latency': 0.008684807256235827, 'default_high_input_latency': 0.034807256235827665, 'default_high_output_latency': 0.034807256235827665, 'default_samplerate': 44100.0}\n```\n\n#### cooldown\n\n| Option | Environment variable | Data type | Unit | Default |\n|------------|---------------------------|-----------|-------|---------|\n| `cooldown` | `RINGR_DETECTOR_COOLDOWN` | float | secs. | 10 |\n\nCooldown time in seconds after a detection. Any sample during this period will be discarded and will not be analyzed.\n\n#### block_duration\n\n| Option | Environment variable | Data type | Unit | Default |\n|-----------|--------------------------------|-----------|------------|---------|\n| `block_duration` | `RINGR_DETECTOR_BLOCK_DURATION` | float | millisecs. | 50 |\n\nDuration of the sample to analyze.\n\nHigher values may provoke input overflow errors.\n\n#### log_analysis\n\n| Option | Environment variable | Data type | Unit | Default |\n|----------------|-------------------------------|-----------|------------|---------|\n| `log_analysis` | `RINGR_DETECTOR_LOG_ANALYSIS` | bool | | False |\n\n\nVerbose output of analysis. Use with log level = debug\n\n### Notification backends\n\nThe configuration of the chosen notification backend is defined inside the `[notifier]` section of the configuration file.\n\nAll notification backends share one option: `type` which specifies the notification backend to use. The corresponding environment variable for this option is `RINGR_NOTIFIER_TYPE`\n\n\nAvailable notification backends:\n\n| Name | Type | Description |\n| --- | --- | --- |\n| Home Assistant | `ha` | Auto-discoverable MQTT device for Home Assistant |\n| Telegram | `telegram` | Telegram Bot |\n\n\n#### Home Assistant\n\nUse `type: ha`\n\n| Option | Environment variable | Data type | Default | Description |\n|-------------|------------------------------|-----------|------------|-------------------------------------------------------------------------------------------------------------------------|\n| `device_id` | `RINGR_NOTIFIER_DEVICE_ID` | str | ringr_01 | Unique device id. Override this value if you run multiple instances of *ringr* |\n| `device_name` | `RINGR_NOTIFIER_DEVICE_NAME` | str | ringr 01 | Device name. Override this value if you run multiple instances of *ringr* or to use a custom name within Home Assistant |\n| `mqtt_host` | `RINGR_NOTIFIER_MQTT_HOST` | str | | Host of the MQTT broker |\n| `mqtt_port` | `RINGR_NOTIFIER_MQTT_PORT` | int | 1883 | Port of the MQTT broker |\n| `mqtt_user` | `RINGR_NOTIFIER_MQTT_USER` | str | | Optional username to authenticate with the MQTT broker. Use it together with `mqtt_pass` |\n| `mqtt_pass` | `RINGR_NOTIFIER_MQTT_PASS` | str | | Optional password to authenticate with the MQTT broker. Use it together with `mqtt_user` |\n| `mqtt_client_id` | `RINGR_NOTIFIER_MQTT_CLIENT_ID` | str | `ringr_01` | Client id of the MQTT client. Override this value if you run multiple instances of *ringr* |\n| `mqtt_qos` | `RINGR_NOTIFIER_MQTT_QOS` | int | 1 | MQTT QoS of published messages |\n\n#### Telegram\n\nUse `type: telegram`\n\n| Option | Environment variable | Data type | Default | Description |\n|-------------|------------------------------|-----------|------------|---|\n| `api_token` | `RINGR_NOTIFIER_API_TOKEN` | str | | Telegram Bot API Token |\n| `chat_id` | `RINGR_NOTIFIER_CHAT_ID` | str | | Telegram Chat ID |\n| `message` | `RINGR_NOTIFIER_MESSAGE` | str | Event detected | Message to send where an event is detected |\n\n### Full example\n\nConfiguration file:\n\n```python\n[detector]\ndevice: 1\nthreshold: 65\npeak_duration: 0.8\nfrequency: 1000\nacceptance_ratio: 90\ngain: 200\nlatency: 0.1\ncooldown: 15\n\n[notifier]\ntype: ha\nmqtt_host: 10.10.0.50\nmqtt_user: ringr\nmqtt_pass: secret\n```\n\nOr, by using environment variables:\n\n```bash\nRINGR_DETECTOR_DEVICE='1'\nRINGR_DETECTOR_THRESHOLD='65'\nRINGR_DETECTOR_PEAK_DURATION='0.8'\nRINGR_DETECTOR_FREQUENCY='1000'\nRINGR_DETECTOR_ACCEPTANCE_RATIO='90'\nRINGR_DETECTOR_GAIN='200'\nRINGR_DETECTOR_LATENCY='0.1'\nRINGR_DETECTOR_COOLDOWN='15'\n\nRINGR_NOTIFIER_TYPE='ha'\nRINGR_NOTIFIER_MQTT_HOST='10.10.0.50'\nRINGR_NOTIFIER_USER='ringr'\nRINGR_NOTIFIER_PASS='secret'\n```\n",
"bugtrack_url": null,
"license": "GNU General Public License v3 (GPLv3)",
"summary": "Sound event detection system",
"version": "0.1.4",
"project_urls": {
"Homepage": "https://github.com/albertoalcolea/ringr",
"Source": "https://github.com/albertoalcolea/ringr"
},
"split_keywords": [
"ringr",
" ring",
" sound",
" sound detection",
" audio",
" audio detection",
" frequency analyzer",
" peak detection",
" home assistant"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "22f95ae59426efa962efda10c0fa06c66eb711499b43fd3caf39902d1125b9ac",
"md5": "ee5b7cdad30f03de299dce9fd039ab79",
"sha256": "caaa50a7a22a4299232bc56ff5c51a4d633fbc6f1ac2745dad1b542196987f92"
},
"downloads": -1,
"filename": "ringr-0.1.4-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "ee5b7cdad30f03de299dce9fd039ab79",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.9",
"size": 25444,
"upload_time": "2024-08-08T19:01:48",
"upload_time_iso_8601": "2024-08-08T19:01:48.116237Z",
"url": "https://files.pythonhosted.org/packages/22/f9/5ae59426efa962efda10c0fa06c66eb711499b43fd3caf39902d1125b9ac/ringr-0.1.4-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-08 19:01:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "albertoalcolea",
"github_project": "ringr",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "sounddevice",
"specs": [
[
"==",
"0.4.6"
]
]
},
{
"name": "numpy",
"specs": [
[
"==",
"1.26.2"
]
]
},
{
"name": "paho-mqtt",
"specs": [
[
"==",
"1.6.1"
]
]
}
],
"lcname": "ringr"
}