Howto create battery alert without creating a template for every device

It’s working! Had to wait a little for the battery entities to show up one by one.

Tnx!! :smile:

Thanks a lot for your help!!
Sorry for my late response but i’m In vacancy!! :slight_smile:
I have also other duplicated sensor how can I hide or delete the other sensor?
It’s seems that the script have make the battery sensor for all my devices so can read the Battery value from my sensor and the battery value from sensor created by the script…

Low Battery Levels

Pulsante Faro Parcheggio (87) ( battery from my sensor)

Pulsante Faro Parcheggio Battery (87) (Created by the script)

Is it still working for you with hass 0.98.x ?
My battery levels stop updating after upgrade.

I’m on 0.98.1 and as far as i can tell, it still works as with previous versions (although my devices somehow are reporting the same level for moths, but that is both through this code as well as directly when viewing the devices/entities/attributes)…

I use google_maps component and it reports my phone battery level.
And since 0.98 it’s stuck at 52% (few days ago since I use 0.98 since first beta).

Don’t know how to debug that.

Are you using the latest version of the code for google_maps? See for instance Google Maps Location tracker - #2 by eggman .

It looks like you’re right.
Sorry about that but I was sure I had checked the value in the device_tracker and it was correct.
I’ve updated my cookie and now it looks fine.
I’ll continue monitoring this.

I manually installed this as a package. Can somebody please point me to the code I need to add to my lovelace to get this view?

Thanks @NotoriousBDG for this great package. A few people have asked about the issue with the Xiaomi Temp sensors and how they create 3 sensors per device (temp, pressure and humidity) which results in 3 battery entities. The advice has been to use the “battery_sensor_creation_disabled” flag to remove the excess.

Trouble is for me I have a lot of these and some others that have 2 sensors so the inhibit list is way bigger that the list of actual batteries I want to monitor which kind of defeats the purpose of this script.

My question is - Is it possible to wildcard the list so it gets smaller. For example I would like to go from this (which is not my complete list!)

sensor.air_quality_sensor_pms_70_0_0:
battery_sensor_creation_disabled: true
sensor.air_quality_sensor_pms_70_0_1:
battery_sensor_creation_disabled: true
sensor.air_quality_sensor_pms_70_0_2:
battery_sensor_creation_disabled: true
sensor.pressure_158d0001f505f1:
battery_sensor_creation_disabled: true
sensor.pressure_158d0001fa38b3:
battery_sensor_creation_disabled: true
sensor.pressure_158d0001fa38df:
battery_sensor_creation_disabled: true
sensor.pressure_158d0001b95353:
battery_sensor_creation_disabled: true
sensor.humidity_158d0001b95353:
battery_sensor_creation_disabled: true

to

sensor.air_quality_sensor_:
battery_sensor_creation_disabled: true
sensor.pressure_:
battery_sensor_creation_disabled: true
sensor.humidity_:
battery_sensor_creation_disabled: true

I was hoping to get this working too, but at the moment, I don’t believe this is compatible with LoveLace. At least, I can’t get the configuration screen either :frowning:

@Simon_Funnell

This is the card for the control panel.

type: entities
entities:
  - input_boolean.low_batteries
  - input_number.battery_alert_threshold_min
  - input_number.battery_alert_threshold_max
  - input_text.delete_battery_sensor
  - input_text.notifier_name
  - input_select.notifier_format
  - automation.battery_persistent_notification
  - automation.battery_persistent_notification_clear
  - automation.battery_notification_default
  - automation.battery_notification_slack
  - automation.battery_sensor_from_attributes
  - automation.update_battery_status_group_members
  - automation.delete_battery_sensor
title: Batterien Alarm
show_header_toggle: false

I got it like this

  • disable lovelace yaml in configuration
  • restart Home Assistant
  • (re-)enable customizing lovelace UI in browser
  • open raw editor
  • copy content to yaml file
  • re-enable lovelace yaml in configuration

Aha, Bingo! Thanks for that :smiley: Seems to be working with my Tradfri remotes nicely!

anyone have the lovelace conffiguration for this template?

Post 650 has all of the Lovelace configs.

2 Likes

So for my understandig. If your not already having a history integration added you should add the one you posted or add it to it correct?

But I think in my situation I should also need to modify recorder settings because I tried to get rid of all logging available with below recorder config:

recorder:
  purge_keep_days: 5
  purge_interval: 1
  exclude:
    domains:
      - automation
      - binary_sensor
      - camera
      - calendar
      - cloud
      - device_tracker
      - group    
      - kodi
      - light
      - media_player
      - mqtt
      - notify
      - sensor
      - script
      - stream
      - sun
      - switch
      - timer
      - updater
      - weblink
      - yeelight
      - zone

And my last question. When using the build in Mosquitto broker HassIO addon and the automaticly added MQTT integration should you still need to make that MQTT config changes in your configuration.yaml? Discovery is already enabled, not sure about the prefix but not sure if i need it becasue i’m already seeing corret battery levels.

##  2. Enable MQTT Discovery by adding `discovery: true` and
##     `discovery_prefix: homeassistant` under the `mqtt:` section
##     of your configuration.yaml
##
##     mqtt:
##       discovery: true
##       discovery_prefix: homeassistant

Hey
To start a discussion about: battery_alert_disabled: true…

Everything work except excluding theese two sensors from alerting. Why?

My code (within the package):

homeassistant:
  customize:
    #To disable alerts for a specific entity
    sensor.saras_batteri:
      battery_alert_disabled: true
    sensor.hugos_batteri:
      battery_alert_disabled: true

I dont want alert from phonebatteries… :neutral_face:

@NotoriousBDG

This might be answered already… Please guide to the right solution :slight_smile:
Since the majority of entities comes with an additional battery level entity I won’t to create a simple automation that tracks all the

sensor.xxxxxxxxx_battery_level

and triggers when one of them is below a given value.

Is there a simple way to track these? Have briefly looked through the posts but I can’t make an overview of the most correct way of doing this at the moment - could someone please help me? :slight_smile:

Is there a reason why text notifications are only sent at 10AM and 6PM or when the thresholds are adjusted? Any suggestions on triggers to send a notification as soon as a battery gets below the set threshold or am I missing something?

it setup in the automation called “battery_notification_default”


- alias: battery_notification_default
  initial_state: 'on'
  trigger:
    - platform: time
      at: '10:00:00'
    - platform: time
      at: '18:00:00'
    - platform: state
      entity_id:
        - input_number.battery_alert_threshold_min
        - input_number.battery_alert_threshold_max
  action:

Fairly new to HA, but tracking battery status was a top item on my list so this was implemented pretty quickly in my setup. Pretty easy to setup and does a great job @NotoriousBDG! Thanks for all the work on this!

Last night I decided that I wanted to monitor the battery level on my boys’ ipads. So I install the IOS app on each of them. Unfortunately it appears that the current version of the app creates a handful of sensors for each device, see below.

The code to update group.battery_status now picks up sensor.battery_level and sensor.battery_state, see below.

For now, I’ve decided just to disable these sensors by going Configuration > Integrations > Mobile App: {device name} iPad and toggling them disabled in there. It’d be nice if these sensors could be ignored or skipped over. Especially since one of them doesn’t even report a percentage, as seen below*

*Yes, the battery level’s don’t match perfectly for Caleb’s ipad, that’s next on my list of things to explore.