Present Phone Battery Charge % To Be Used as Trigger

I use Tasker and SharpTools for my phone charger and it works great. I use it to control a smart switch at home and a smart switch at camp.


Nice, but i’m new at this and dont know how to make it work in sharptools :confused:
I found one guide (different than your screenshots) but i dont know how to …

Can you help me on sharptools side?

You will need the SharpTools plug in for Tasker. I think it costs $3.50 US.

You need to install the SharpTools app (Android or iOS) and link it to ST. It will show up as a smart app in ST.

Open the SharpTools smart app in ST and select the devices you want to be available in SharpTools.

After you do that go back to Tasker and create a “task” using the SharpTools plug in. You should be able to chose the device in SharpTools that you want to operate.

If you have a Samsung phone with Bixby, a Bixby routine is easily set up to accomplish the charge on off battery level task.

1 Like

I’ve been trying to get Tasker and LAN trigger device made by @TAustin to work together so routines like this would run locally. No luck so far. There’s something I’m doing wrong, I just can’t figure out what it is.

If you are going down the Tasker route you could just turn a charger on and off using an API call. An alternative would be to create a virtual battery device (I use the @TAustin driver) and update that using the API. I favour the latter as it gives you the battery and power source in SmartThings where it really ought to be already.

Here is an example of an HTTP Request in Tasker. It requires knowledge of the device ID in UUID form, and also a suitably scoped Personal Access Token for the bearer authorization.

2 Likes

I’m slowly starting to get hang of this. But bare with me, I’m novice with these things. Under the Query Parameters I have FIle/Directory To Save With Output. Is is that part where the piece of code should be? Is it a file you have uploaded from the files of your phone?

Can you elaborate on this at all? This is something I’ve been wanting to do for a while, but couldn’t find a way to do it through SharpTools. I’ve created a new virtual battery device using the vEdge Creator from TAustin, I have the UUID of the battery device, and have created a PAT with (I believe) appropriate authorized scopes. I’m pretty familiar with Tasker etc., but I’m still getting an error when I try to run the task. Any tips? TIA!

What error are you getting?

1 Like

Jebus you’re responsive. :slight_smile: The error is… vague.

I tried changing the method to different things which give, for example, “POST is not an allowed HTTP method for the requested resource.”

That last line with just the E is where I would expect the actual error. IIRC, there’s a variety of different Tasker variables that get set with response codes and things like that. I would either Notify > Flash those variables or store them to global variables so you can review and see if they have any meaningful data.

Have you used HTTP Actions in Tasker before? At least one other person mentioned that they got a generic error like that when Tasker didn’t have the required permissions it needed on Android 12.

Otherwise if you try to do it with the SharpTools Tasker plugins, I’d be happy to help out since I wrote them. :slight_smile:

1 Like

That’s odd, because executing device commands is definitely a POST.

Wow! This looks exciting.

What does the ‘Powersource’ show and does it change conditions when AC power is available and when it isn’t? If so, can the powersource condition be used as a trigger for Routines?

Update: I was able to get this Tasker profile working so it can change the vEdge Battery device, but the vEdge Battery device is broken trying to use the Power Source as an If condition in a Routine.

I did notice that Tasker does not have a native %POWERSOURCE variable, so to get this to work, I created two Tasker Profiles to set the %POWERSOURCE variable to either Mains or Battery depending on the AC power source before the HTTP Request.

I can’t save the Routine to test it at the moment but I thought I’d tested it previously.

Oops, I’d forgotten what I’d done. I use a single Profile based on the Power state being ‘Any’, with anonymous tasks to set the variable to dc or battery and send the HTTP request when it becomes active and inactive.

I find Tasker to be simultaneously brilliant and borderline unusable and the less I think about it the better.

After getting a good night’s sleep, I took another stab at this and immediately found my issue: I’m an idiot. I missed the “/commands” at the tail end of the URL :man_facepalming:

Thanks to everybody for your help, without it I would have given up.

Also, @joshua_lyon I still can’t get SharpTools to even show the virtual battery device in the “Authorize Things” screen. Not sure if that’s a feature or a bug, but it would probably make this easier for people like me who use SharpTools a ton.

I am following your instructions for Present Phone Battery Charge % To Be Used as Trigger to use on one of my task but I can not figure why the request will not toggle the light (Sengled z01-a19nae26 is using Edge Zigbee Switch)? I am have been informed the Edge Zigbee device must have toggle capabilities for the Tasker task to run. Any ideas or suggestions?

In order to implement a ‘toggle’, something, somewhere, is implementing the logic ‘if the switch is already on then turn it off, or if the switch is already off then turn it on’. There appears to be an undocumented Rule action for this which Routines are using, but otherwise the Routine would implement it with the basic conditions and actions. You either have to implement that logic in Tasker or shift the problem elsewhere.

My preference is not to attempt to use Tasker as an automation engine, but instead to use it in combination with virtual devices in SmartThings as part of the device integration. A DIY cloud connected device in effect. So in the case of battery level I would define a virtual battery in SmartThings and use Tasker to set it (which is what my earlier example shows). You then have a device in SmartThings you can use as you wish.

It is essentially the same idea as what you are already implementing with your virtual presence sensor.

1 Like

Ok so I may need to explain what I am trying to accomplish… I am using Bubble Cloud Launcher for WEAR OS and it lets us use Tasker to send task from the Tasker task list (workaround due to new Smartthings Edge platform). From there we setup icons and when we press the icon it running the task to Smartthings (turn on, off, or toggle light). Bubble Cloud Launcher for WEAR OS must pull from the Tasker task list to preform command to Smartthings. I thought your post mentioned above would help me to accomplish what I am trying todo in the WearOS Cloud launcher with light toggling?



Ah I see. In that case I can see why you might find it more appealing to have Tasker send a ‘toggle’ directly. That is perfectly viable in Tasker, you just have to first use the SmartThings API to query the current state of the switch and then choose to send either on or off. I can’t suggest the details as I was never that fluent in Tasker and I have deleted it from all my devices.

I’d probably just execute a Rule myself but that’s me.

1 Like

Could you just have Tasker turn on a virtual momentary switch? Then, have a SmartThings routine that toggles your desired light every time the virtual momentary switch turns on.