Automation to turn on/off switch to charge fire tablet

Hi all, I am trying to save the fire tablet battery by automating a switch to charge the tablet based on the battery level. The automation is never triggered. What is wrong in the code

alias: Fire Tablet Battery Saver
description: “”
trigger:

  • type: battery_level
    platform: device
    device_id: 3e532b1d294b63dc9517e9e83daf866b
    entity_id: sensor.firetab_battery_level
    domain: sensor
    below: 20
    condition: []
    action:
  • type: turn_on
    device_id: adf7d65d047a3adbcc6fcd5a6cf00528
    entity_id: switch.outlet_1
    domain: switch
  • wait_for_trigger:
    • type: battery_level
      platform: device
      device_id: 3e532b1d294b63dc9517e9e83daf866b
      entity_id: sensor.firetab_battery_level
      domain: sensor
      above: 85
      continue_on_timeout: true
  • type: turn_off
    device_id: adf7d65d047a3adbcc6fcd5a6cf00528
    entity_id: switch.outlet_1
    domain: switch
    mode: single

You really need to format the paste when you paste code or people have trouble helping you…

But the code, from what I can tell, looks fine but have you checked that sensor and can you see it has actually dropped below 20? I am not asking about the device battery itself. I am talking about the sensor for the battery in home assistant… You can see that in the history.

On a side note, I doubt you’re causing any issues by just leaving it in. Tablets stop charging when they are full and will just top it off every now and then. By turning that switch on/off, you’re actually going to hurt the battery more by cycling it than trickle charging it.

Thanks a lot for your reply, for future interactions in the forum, I was looking for help from other members unless I posted in a wrong forum or room.

The battery sensor is updating HA but not regularly. I integrate the tablet by installing HA app on it.

Is there a better way to get the battery level in HA ?

I have been using this… But it might not be what you want.
https://community.home-assistant.io/t/wallpanel-battery-management/256317

1 Like

Implemented the blueprint, will let you know the result :blush:

Thanks for the help

Update on the blueprint, it works super fine.
Thanks a lot :blush:

1 Like

After researching the best way to reserve the battery I found that the best way is to change the routine, putting the tablet on charger 24/7 is ok but it shorten the battery life, power cycling is also ok but it should not happen always.

So I scheduled the automation to run on selected weekdays only, the rest of the days the charger is on.

May be it helps others :slight_smile: