Phone battery percentage into HE

Hello,
Been using hubitat awhile now and love it
I have
C7
platform version - 2.3.6.146

I have seen several posts on getting battery percentage into HE. I have tried doing http with Tasker and Maker api. I have been using Tasker for 5 years so know it very well. Maker API very new and no success yet. When I run the task in tasker I get an error. "Device not found or error". Does the phone need to be rooted ? Does there need to be a port noted ?

this is what I used in tasker - (the xs would have actual IP)

http://xxx.168.xx.113/apps/api/489/devices/753/setBattery/%BATT?access_token=xxxxxxxx

Is this right ?

I edited out your access token for you, I would be more worried about that than your internal IP address.

Does this device 753 have a "setBattery" command?

1 Like

Thank you very much appreciate the edit. Yes it does is blank now

The attribute is what would be blank, but for the command buttons there would need to be a "setBattery" command for this to work.

Maybe post a screenshot of the device page, and also what device type/driver are you using?

Hi JTP,
I am using Simon burke's driver

I did try putting in 50 then hitting set command and that is what appeared on the right.

FYI link to driver - [RELEASE] Virtual Battery Sensor

At the moment Tasker is giving me a different error I looked at battery percentage and check what it was in tasker so changed it to %bi_level. This changed error to error 400 in tasker

The structure of the Maker API call looks ok at a glance. Is your Maker API app in HE app 489? This will appear in the URL in a browser if you open Maker API.

Yes it is 489 just re-verified.

In the maker app under select devices. Do I select the phone that I am trying to get percentage from ?
In the URL to post device events I have 753 on the very end.

New to using Maker API so not sure my settings are correct.

Unfortunately I don't have much more time to assist, but what @jtp10181 was referring to earlier was to check that 753 in your original maker API URL is the device I'd of the device in HE. On the page where you looked at the set battery command and battery percentage, check the URL in the address bar, this should include the device id.

Thanks Simon yes also checked that the device showed 753 at the end of web address in the virtual device

Might be a day or two before I can take a proper look. Hopefully someone else can help you out in the meantime. Otherwise, my tasker project should hopefully make this a little easier.

Thanks Simon greatly appreciated. Was not sure you were finished with that project and is why I was trying to do it manually.

Ya if you can help in a few days that would be great.

if anyone else knows why this is not working let me know. At the moment getting a error in tasker so pretty sure that is the problem. Error 400

Just to make sure, this isn't at the very end, I assume, if the Device Id is 753, then it was in the correct spot in your original URL you posted, as were other elements.

Yes this is correct. Maker API has two main use cases, well three if you want to include modes... In terms of devices you are able to both retrieve details about the device (from the Current States in the Device Detail page) and issue commands, also displayed at the top of the Device Detail page. And so you are right, the list of selected devices is for any device where you want to do either of those two things, retrieve status information or issue a command. In this case, the command is to set the battery reading.

One thing to check is that you have configured the METHOD correctly in Tasker for the HTTP Request, making sure it is set to a GET method in this case.

If you could post a screenshot of your tasker setup that may help. I am wondering whether you are not using a battery level changed event as the trigger in the profile, in which case I don't expect the BATT variable would be available.

Lastly, in case it hasn't been mentioned already... try issuing the HTTP call by posting it into a browser address bar and seeing if you can alter the battery level that way.

Just wanted to post. Simon helped me fix it and I am very grateful Thanks again Simon you are amazing !!!. The problem was in tasker mainly the battery variable I was using. I had requested the battery info in tasker which for current level was %bi_level. I changed this to %BATT and it worked.

Also a second note in the release of the driver Simon had the device, command, and secondary in brackets so when you put in your info don't use brackets. I had tried with and without. My main problem was the battery percentage. Also my Maker app was not setup correctly. I had to add virtual device to list / select it and secondly remove url to post to.

Just thought I'd share for anyone trying to get this to work.
Have a great day and sure love this community

2 Likes