Low Battery Cloud TTS Notification

This automation blueprint sends a Nabu Casa Cloud TTS message to a media player when your device reaches a certain percentage.

Note: you will need a Nabu Casa subscription to use this blueprint.

See the tts.cloud_say docs for available TTS options.

blueprint:
  name: Low Battery Cloud TTS Notification
  description: This blueprint will send a Cloud TTS message when a device's battery
    is low
  domain: automation
  input:
    device:
      name: Device
      description: The device that has a battery level.
      selector:
        entity:
          domain: sensor
          device_class: battery
    media_player:
      name: Media Player
      description: The media player to send the TTS message to.
      selector:
        entity:
          domain: media_player
    media_player_volume:
      name: Media Player Volume (Optional)
      description: Set the media player's volume. (Leave at 0 or unset to leave unchanged)
      default: 0.0
      selector:
        number:
          min: 0.0
          max: 1.0
          step: 0.1
          mode: slider
    message:
      name: Message (Optional)
      description: 'Default: "Battery is low on {{ device_name }}"'
      default: Battery is low on {{ device_name }}
    tts_gender:
      name: TTS Gender (Optional)
      description: 'Default: "female"'
      default: female
    tts_language:
      name: TTS Language (Optional)
      description: 'Default: "en-GB"'
      default: en-GB
    battery_level:
      name: Battery level
      description: What level the device should be to trigger the notification.
      default: 10
      selector:
        number:
          min: 1.0
          max: 100.0
          unit_of_measurement: '%'
          step: 1.0
          mode: slider
  source_url: https://community.home-assistant.io/t/low-battery-cloud-tts-notification/255495
variables:
  battery_level: !input 'battery_level'
  device: !input 'device'
  device_name: '{{ states[device].name }}'
  media_player_volume: !input 'media_player_volume'
trigger:
  platform: numeric_state
  entity_id: !input 'device'
  below: !input 'battery_level'
action:
- choose:
  default:
  - condition: template
    value_template: '{{ media_player_volume != 0.0 }}'
  - service: media_player.volume_set
    entity_id: !input 'media_player'
    data:
      volume_level: '{{ media_player_volume }}'
- service: tts.cloud_say
  entity_id: !input 'media_player'
  data:
    message: !input 'message'
    options:
      gender: !input 'tts_gender'
    language: !input 'tts_language'

What if the battery level isn’t updated every percent? So it jumps from battery_level + 2 to battery_level. It might be better to use the numeric_state platform with a below battery_level trigger. Only problem is it triggers again if its below battery_level and your HA reboots.

I’ve updated the trigger to use a numeric_state trigger instead of a state trigger. This should be more accurate now and will trigger when the value drops below the number set instead of the exact number

Nice blueprint… just a thought though (I had a really quick look through it)…can you set an option for it to repeat itself every, say hour, until the battery is replaced?

that is a good question. I’ve never been able to do a repeated automation (without some nasty hacks), as this breaks the concept of the automation trigger: once a trigger has been triggered it won’t until its trigger condition has changed. In this case as soon as the battery falls below the limit -> the automation is triggered and won’t triggered again as long as the below-condition is true (or nasty hack: the automation is enabled-disabled again).

To overcome that, I use the alert-integration.

Edit:
:thinking: The more I think about it, it might be possible nowadays using a repeat-count-action and delays
Here is a draft example of an generic nagging alert notifiton: Nagging Alert Notification

Thanks @pavax i’ll check it out… Keep up the good work!

Thanks a ton for this Blueprint, Exactly what I need to get the kids to keep their phones charged. I also need it to nag (read irritate :grin:) the kids to get them to charge their phones so will investigate the Nagging Alert. ( Something along the lines of "if battery level is below 12% and state is not charging, nag every 15 minutes, at increasing volume increments.) Also, I will need to find a way to tweak the Google Home Mini playback and volume. (Music playback stops and does not resume after TTS notification. This is life threatening, wife wants to kill me. :grin:. )