Skip to content

Commit

Permalink
Timers and chimes (#74)
Browse files Browse the repository at this point in the history
* Add notification sounds

* Add substitutions for the sound URLs

* Add sound notifications for wakeup, VAD end and error

* Add timer support

* Change audio files

* Add notification sound license to README

* Change notification file URLs

* Rework sound notifications and remove VAD end

* Add README instructions

* Bumped min versions in README

* Remove commented out line

* Bump min ESPHome version

* Port to non MWW version

* Bump project version
  • Loading branch information
tetele authored Aug 7, 2024
1 parent 94f3bbc commit d6d66ea
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 7 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The PCB is **NOT** my work and has [its own license](https://github.com/justLV/o

The config is distributed under the **MIT** License. See [`LICENSE`](LICENSE) for more information.

The notification sounds used are under [CC BY 4.0 ATTRIBUTION](https://creativecommons.org/licenses/by/4.0/) license.

## Features

- wake word (including [microWakeWord](https://www.esphome.io/components/micro_wake_word) in an experimental phase), push to talk, on-demand and continuous conversation support
Expand All @@ -27,9 +29,9 @@ The config is distributed under the **MIT** License. See [`LICENSE`](LICENSE) fo

## Pre-requisites

- Home Assistant 2024.2.0 or newer
- Home Assistant 2024.7.0 or newer
- A voice assistant [configured in HA](https://my.home-assistant.io/redirect/voice_assistants/) with STT and TTS in a language of your choice
- ESPHome 2024.7.0 or newer
- ESPHome 2024.7.3 or newer

## Known issues and limitations

Expand All @@ -49,6 +51,14 @@ Double check Wifi connection details, API encryption key and device name/friendl

After the device has been added to ESPHome, if auto discovery is turned on, the device should appear in Home Assistant automatically. Otherwise, check out [this guide](https://esphome.io/guides/getting_started_hassio.html).

### Notification sounds

Although the online MP3 files should work, downloading them implies some lag. It's far better to have them locally available.

1. Create a folder named `sounds` in your `config` folder under `www`. You now have a `config/www/sounds` folder.
1. Upload notification sounds in the folder (MP3 prefferable, to avoid encoding issues), e.g. `error.mp3`
1. Replace the URL in the `substitutions:` section with your own URLs (e.g. `http://homeassistant.local:8123/local/sounds/error.mp3`). If your HA instance is available at `http://homeassistant.local:8123/`, then whatever you upload to the `www` folder is available at `http://homeassistant.local:8123/local/`

## Credits

- obviously, a huge thanks to [Justin Alvey](https://twitter.com/justLV) (@justLV) for the excellent Onju Voice project
Expand All @@ -57,6 +67,7 @@ After the device has been added to ESPHome, if auto discovery is turned on, the
- thanks to [@gnumpi](https://github.com/gnumpi) for migrating the ESPHome [`media_player` component to ESP-IDF](https://github.com/gnumpi/esphome_audio)
- thanks to [Klaas Schoute](https://github.com/klaasnicolaas) for helping with a creating a microsite for the automatic installation of this config (still experimental)
- thanks to the [ESPHome Discord server](https://discord.gg/KhAMKrd) members for both creating the most time saving piece of software ever and for helping out with some kinks with the config - in particular @jesserockz, @ssieb, @Hawwa, @BigBobba
- thanks to [UNIVERSFIELD](https://freesound.org/people/UNIVERSFIELD/) for the notification sounds (licensed [CC BY 4.0 ATTRIBUTION](https://creativecommons.org/licenses/by/4.0/), slightly shortened and converted to mono)

If you'd like to thank me for creating and maintaining this config, you can [![GithubSponsor][githubsponsorbadge]][githubsponsor]

Expand Down
30 changes: 28 additions & 2 deletions esphome/onju-voice-microwakeword.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
substitutions:
name: "onju-voice"
friendly_name: "Onju Voice Satellite"
project_version: "1.0.0"
project_version: "1.1.0"
device_description: "Onju Voice Satellite with ESPHome software and microWakeWord"
wakeup_sound_url: "https://github.com/tetele/onju-voice-satellite/raw/main/res/wakeup.mp3" # New Notification #7 by UNIVERSFIELD https://freesound.org/people/UNIVERSFIELD/sounds/736267/
error_sound_url: "https://github.com/tetele/onju-voice-satellite/raw/main/res/error.mp3" # Error #8 by UNIVERSFIELD https://freesound.org/people/UNIVERSFIELD/sounds/734442/
timer_finished_sound_url: "https://github.com/tetele/onju-voice-satellite/raw/main/res/timer_finished.mp3" # New Notification #6 by UNIVERSFIELD https://freesound.org/people/UNIVERSFIELD/sounds/734445/

external_components:
- source:
type: git
Expand All @@ -18,7 +22,7 @@ esphome:
project:
name: tetele.onju_voice_satellite
version: "${project_version}"
min_version: 2024.7.0
min_version: 2024.7.3
platformio_options:
board_build.flash_mode: dio
board_build.arduino.memory_type: qio_opi
Expand Down Expand Up @@ -207,6 +211,10 @@ micro_wake_word:
condition: media_player.is_playing
then:
- media_player.pause
- media_player.play_media: "${wakeup_sound_url}"
- wait_until:
not:
media_player.is_playing: onju_out
- voice_assistant.start:
wake_word: !lambda return wake_word;

Expand Down Expand Up @@ -250,6 +258,20 @@ voice_assistant:
- binary_sensor.is_off: mute_switch
then:
- micro_wake_word.start
on_timer_started:
- light.turn_on:
id: top_led
effect: random_twinkle
on_timer_finished:
- media_player.play_media: "${timer_finished_sound_url}"
- light.turn_on:
id: top_led
blue: 0%
red: 100%
green: 80%
effect: slow_pulse
- delay: 5s
- script.execute: reset_led
on_client_connected:
- if:
condition:
Expand All @@ -268,6 +290,7 @@ voice_assistant:
- voice_assistant.stop:
- micro_wake_word.stop:
on_error:
- media_player.play_media: "${error_sound_url}"
- light.turn_on:
id: top_led
blue: 0%
Expand Down Expand Up @@ -468,6 +491,9 @@ light:
- addressable_flicker:
name: speaking
intensity: 35%
- addressable_random_twinkle:
name: random_twinkle
twinkle_probability: 45%
- platform: partition
id: right_led
segments:
Expand Down
26 changes: 23 additions & 3 deletions esphome/onju-voice.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
substitutions:
name: "onju-voice"
friendly_name: "Onju Voice Satellite"
project_version: "1.0.0"
project_version: "1.1.0"
device_description: "Onju Voice Satellite with ESPHome software"
error_sound_url: "https://github.com/tetele/onju-voice-satellite/raw/main/res/error.mp3" # Error #8 by UNIVERSFIELD https://freesound.org/people/UNIVERSFIELD/sounds/734442/
timer_finished_sound_url: "https://github.com/tetele/onju-voice-satellite/raw/main/res/timer_finished.mp3" # New Notification #6 by UNIVERSFIELD https://freesound.org/people/UNIVERSFIELD/sounds/734445/

esphome:
name: "${name}"
Expand All @@ -12,7 +14,7 @@ esphome:
project:
name: tetele.onju_voice_satellite
version: "${project_version}"
min_version: 2024.6.0
min_version: 2024.7.3
platformio_options:
board_build.flash_mode: dio
board_build.arduino.memory_type: qio_opi
Expand Down Expand Up @@ -136,7 +138,7 @@ media_player:
mute_pin:
number: GPIO21
inverted: True
on_state:
on_state:
then:
- lambda: |-
static float old_volume = -1;
Expand Down Expand Up @@ -190,6 +192,20 @@ voice_assistant:
not:
media_player.is_playing: onju_out
- script.execute: reset_led
on_timer_started:
- light.turn_on:
id: top_led
effect: random_twinkle
on_timer_finished:
- media_player.play_media: "${timer_finished_sound_url}"
- light.turn_on:
id: top_led
blue: 0%
red: 100%
green: 80%
effect: slow_pulse
- delay: 5s
- script.execute: reset_led
on_client_connected:
- if:
condition:
Expand All @@ -207,6 +223,7 @@ voice_assistant:
then:
- voice_assistant.stop:
on_error:
- media_player.play_media: "${error_sound_url}"
- light.turn_on:
id: top_led
blue: 0%
Expand Down Expand Up @@ -407,6 +424,9 @@ light:
- addressable_flicker:
name: speaking
intensity: 35%
- addressable_random_twinkle:
name: random_twinkle
twinkle_probability: 45%
- platform: partition
id: right_led
segments:
Expand Down
Binary file added res/error.mp3
Binary file not shown.
Binary file added res/timer_finished.mp3
Binary file not shown.
Binary file added res/wakeup.mp3
Binary file not shown.

0 comments on commit d6d66ea

Please sign in to comment.