Automation trigger battery level

Hello Guys,

I want to get a notifcation when my iPad is below 10% battery.

Here is my code:

- id: ipad_low_battery
  alias: iPad unter 10% Akku
  trigger:
    platform: numeric_state
    entity_id: sensor.robins_ipad_battery_level
    below: 10
  action:
    service: notify.iPhone
    data:
      message: iPad below 10% battery. Please recharge

The notification works but the trigger not. Maybe someone can help.

Daranto

Quick test in template dev tool shows that the value stored in the iOS battery level is a string not an integer. So you can’t use it as a numeric_state.
you could use a template trigger and do the conversion like this:
> {{states.sensor.sensor.robins_ipad_battery_level.state | int<10}}

1 Like

Hello,

thanks for your answer. Is this correct?:

- id: ipad_low_battery
  alias: iPad unter 10% Akku
  trigger:
    platform: template
    value_template: "{{states.sensor.sensor.robins_ipad_battery_level.state | int<10}}"
  action:
    service: notify.iPhone
    data:
      message: iPad unter 10% Akku. Bitte aufladen!

Daranto

1 Like

looks right to me

You should also check the alert component as it may be more suited for battery level alert. (works basically the same way but keep notifiying every X minutes until you perform the action (either acknowlege in frontend or recharge the iPad).

What are you using to get the battery level from the iPad?

Hey, Im using the iOS App from Home-Assistant for the battery level sensor.

Daranto