Low iPhone battery

Anyone see anything wrong with the below code (automation.yaml). It works fine testing using the dev tools though when the battery gets to below 30% it does not send a message?

Cheers

   - alias: Jaz's low iPhone battery
     hide_entity: true
     trigger:
        platform: template
        value_template: "{{ sensor.jazs_8_battery_level.state | int < 30}}"
     action:
      service: notify.ios_jazs_8
      data:
        title: "Low battery warning"
        message: "Please recharge your battery soon!"

EDIT:

Just changed

value_template: "{{ sensor.jazs_8_battery_level.state | int < 30}}"

to

value_template: "{{ sensor.jazs_8_battery_level.state < 30 }}"

& will see what happens (dev tools worked fine again)

You should be able to use the numeric_state trigger instead, this is the automation I use on my wall mounted tablets,

alias: Tablet Battery Charge on
  trigger:
  - below: '21'
    entity_id: sensor.display_kitchen_tablet_battery
    platform: numeric_state
  condition: []
  action:
  - data:
      entity_id: switch.plug_3
    service: switch.turn_on
2 Likes

Thanks for that. My alteration didn’t work & I have now gone with your suggestion & will post back.

   - alias: Jaz's low iPhone battery
     hide_entity: true
     trigger:
      - platform: numeric_state
        below: '21'
        entity_id: sensor.jazs_8_battery_level 
     action:
       service: notify.ios_jazs_8
       data:
        title: "Low battery warning"
        message: "Please recharge your battery soon!"
1 Like

you can obviously change that number to whatever you want, so if you just want to test it works, change it to the number 2 below what your phone currently is at, and then just wait a bit, rather than having to wait all the way till it gets low :wink:

lol good point - will do :slight_smile:

EDIT:

Yep that worked - ‘Thank You’

1 Like

Thanks so much…this worked for me too…!!

1 Like