Charge My Android Tablet automatically When Battery goes less than 10% & Stop Charging when 100%

Hi ,
I am planning to have my old Android tablet as HA Dasboard on my wall.
The setup in my mind is to Connect the Android tablet to a Sonoff Socket (Tasmotised) & hang it to the wall.
I am thinking if I can automatically Charge My Android Tablet say when Battery goes less than 10% the Sonoff should Turn ON automatically. Similarly, Stop Charging my Android tablet when Fully charged, (100% charge is reached)

Is this possible using HA Automation?

If so How??

Please guide. Thanks, in advance.

I would assume you need to download the home assistant app onto your android device and link it up to your home assistant. It will show up as a device_tracker device. You should be able to pull the battery percentage out of it.

I’m sure there are other ways as well but you may need to know more about the android os.

I dont see home assitant android app in my play store
Can you help

I don’t have an android, i have an iphone. There is an iOS app and i assumed there was an android app because it’s easier to develop for android than iOS.

1 Like

Is this the app You are mentioning? I feel dosent seem life official app
https://play.google.com/store/apps/details?id=com.axzae.homeassistant

I tried installing this but after that how do i show up as a device_tracker & retrive battery %

Please clarify

I have just set this up last night. The way I did it was using Fully Kiosk Browser, and the custom display component from @daemondazz here, Display platform and Fully Kiosk Browser component

I created a template sensor that read’s the battery value in HA,

- platform: template
  sensors:
    display_kitchen_tablet_battery:
      value_template: '{{ states.display.kitchen_tablet.attributes.battery_level }}'
      friendly_name: 'Kitchen Tablet Battery'
      unit_of_measurement: "%" 
      device_class: battery 

and then I setup an automation to charge it when it gets low, and switch off when it gets full,

- id: '1532547735836'
  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
- id: '1532548478810'
  alias: Tablet Battery Charger off
  trigger:
  - above: '99'
    entity_id: sensor.display_kitchen_tablet_battery
    platform: numeric_state
  condition: []
  action:
  - data:
      entity_id: switch.plug_3
    service: switch.turn_off

Hopefully this will help you out, or at least point you in the right direction. Any problems, just shout.

1 Like

Thanks for the reply

I understand the automation part , its great exactly what i want

(Am a newbie to HA) BUT, I don’t understand how the template sensor component fetches the android phone/tablet battery %??

I use hassio& is running on Rasberry pi

please clarify

https://www.ozerov.de/fully-kiosk-browser/ you run this app on your tablet to display HADashboard, and that app can give you a sensor in HA with the method I described above which will give you the battery readout.

1 Like

Oh ok got it
I will give it a try & keep u posted for queries.

After Installing the Kiosk Browser on my Tab & loading HA dashboard URL
& adding template sensor Code in Config.yamal
i see the following Image in my HA with No Sensor value displayed.
Whats wrong i have done? Please help

UI_battery

without posting your code, I have no idea, unfortunately I am not a code reader from afar :slight_smile:

1 Like

I’m reading this because I’m planning to do the same thing. A bit off-topic question though: why so complicated id:s that won’t tell you anything (1532547735836 & 1532548478810)?

Sorry, I’m totally newbie with Home Assistant.

Those ID’s say quite a lot.
They are Unix timestamps so if you convert them to a date you can get the date and time when the automation was created.

If you want to change the ID to something else then do so… it makes no difference.

1 Like

Ah, makes sense now. Thank you!