Android battery level over mqtt in espeasy.

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
nobody@all
Normal user
Posts: 30
Joined: 09 Apr 2017, 23:27

Android battery level over mqtt in espeasy.

#1 Post by nobody@all » 08 Dec 2023, 17:45

Hello:)
Does somebody tryied reading battery status from phone or tablet ?
I want to use old tablet for lcd screen but it will be not offen use and for safety i don't want to have still battery charger connected to it.
My idea is to read every 5min battery status and when it will be less than 20% using relay turn on wall charger and disconnect when be 100%

User avatar
Ath
Normal user
Posts: 3521
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Android battery level over mqtt in espeasy.

#2 Post by Ath » 08 Dec 2023, 21:17

There are a few things to consider here:
- MQTT is a push protocol, so the measured value has to be pushed to a broker to be visible for others. So you can't pull that info by using MQTT.
- Moving the control to an external device, like an ESP unit, might create an undesirable triangle-dependency, maybe it should be more simple

I've used a somewhat different approach:
- Install the Android app Automate (free version with some limitations available, but enough for this purpose)
- Create a flow that checks the battery level, and when below the desired level (20%) send a command (http://ip.of.your.esp/control?cmd=event,poweron) to an ESPEasy-powered Sonoff S20 power plug (other brands/models can also be used, of course) to switch on, then wait for 10 minutes and loop
- Create another flow that checks for battery level 100%, and when reached, wait for an extra hour, the send a command (http://ip.of.your.esp/control?cmd=event,poweroff) to the the plug. Then wait for 10 minutes and loop.

Of course, the events poweron and poweroff have to be added as rules in the ESPEasy unit:

Code: Select all

on PowerOn do
  gpio,12,1
endon
on PowerOff do
  gpio,12,0
endon
Works like a charm :)
/Ton (PayPal.me)

nobody@all
Normal user
Posts: 30
Joined: 09 Apr 2017, 23:27

Re: Android battery level over mqtt in espeasy.

#3 Post by nobody@all » 10 Dec 2023, 21:49

Thank You for reply, thank You Very much!
I will try in free moment of time.
:P

Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests