How to Adjust Google Home TTS Volume Based on Ambient Noise

Hey everyone! I’ve been working on a fun project to make my Google Home TTS notifications louder when there’s a lot of noise in the house. I thought I’d share my setup and see if anyone else has tips or tricks for improving this further!

So, the idea is pretty straightforward: use a microphone sensor to measure the ambient noise level and adjust the TTS volume accordingly. If it’s quiet, keep the volume low to avoid being too loud. If it’s noisy, crank it up so the notifications are still heard over the hubbub.

Here’s how I set it up:

  1. Sensor Setup: I used an MQTT sensor to detect noise levels. It publishes the volume in decibels to a topic like ESPD1/volume/volume.
  2. Automations: I created an automation that triggers whenever the noise level changes. It calculates the appropriate volume level based on the decibel reading.
  3. Dynamic Volume Adjustment: The volume level scales from 0.1 (quiet) to 1.0 (loud) as the noise increases from 0 dB to 90 dB.
  4. TTS Notification: Once the volume is set, it triggers a Google Home TTS notification with the adjusted volume.

Here’s the configuration I used:

yaml

  • alias: “Adjust TTS Volume Based on Noise”
    trigger:
    • platform: mqtt
      topic: “ESPD1/volume/volume”
      action:
    • service: media_player.volume_set
      data_template:
      entity_id: media_player.kitchen
      volume_level: >
      {% if soundsensor1.state | int < 50 %}
      0.1
      {% elif soundsensor1.state | int < 70 %}
      0.5
      {% else %}
      1.0
      {% endif %}
    • service: tts.google_say
      data_template:
      entity_id: media_player.kitchen
      message: ‘{{ [“Message1”, “Message2”, “Message3”] | random }}’

I’d love to hear if anyone else has implemented something similar or has suggestions for improving this setup. Maybe adding a delay or smoothing the volume changes could make it even better! Let’s brainstorm together! :rocket: