Battery percentage display

Is there a way to retrieve and display the percentage of the mobile device that is being used. I am attempting to display this percentage in a window, advice on this would be helpful. Thanks

2 Likes

Re: Battery Life Retrieval- In a few words, that depends on whether you are talking about one specific device or a variety. For Instance, On a system that I use: Start Menu>WindowsSystem>Control Panel>All Control Panel Items>Power Options would drill down to where I would choose Dell Extended Battery Life Options and get a display window popup with a Battery Status Tab including a Bargraph. This is great, but you would have to set-up a remote-control type client which some folks might object to. For instance, the Battery Status Tab is accompanied by a Battery Health Tab within the Battery Meter Popup. From the Battery Health Tab, it might be possible to order a new battery online from Dell ( Using their name from your application ). Now while that may seem unlikely, giving you that authority might be easier for them than it would be for you to set up that level of access to their Windows PC. This might be a bit easier on an Android mobile device, provided that all of the ones you wanted to access had the same firmware levels ( essentially all the same hardware ). It might work until someone upgrades the Android OS or just a specific part of the firmware. Thus I would discourage it unless you have a great amount of time and money to engage in the project.

you can use this in the windows command prompt

WMIC PATH Win32_Battery Get EstimatedChargeRemaining

I have no idea if you can execute this in an Ignition Client and return the value, but might be worth trying. If you could do this, you could write the returned value to a tag then bind to a graphic.

2 Likes

Is this question referring to Perspective app, Perspective browser, or something else?

At least for now, the answer to this question is “no”. I could see us adding something like this as a value-add to the mobile applications, but browser support for fetching battery status is limited, and we don’t like to add features that only work on one platform.

This sounds like a good post for ideas.inductiveautomation.com, also - the more community interest, the sooner we’re likely to implement something like this.

1 Like

Okay, thanks for letting me know

I wanted to try something through this route. Thank you for the suggestion

I’ve put this inside actionPerformed event of the Timer component (15seconds) in Vision (not Perspective):

def bateryremaining():
	import subprocess
	proc = subprocess.Popen('powershell.exe -noprofile -command "(Get-WmiObject win32_battery).estimatedChargeRemaining"', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
	tmp = proc.stdout.read()
	print "estimatedChargeRemaining: ", tmp
	system.tag.write("[Client]bateryRemaining", tmp)
system.util.invokeAsynchronous(bateryremaining)

Running client on Windows 10 Pro tablet
and it is working (Ignition v7.9.11)…

3 Likes

This method works in v8. However, I am getting inaccurate info using this.
Value returned doesnt match the value indicated on windows taskbar battery UI.
Does perspective have better support for battery status?

No, support hasn’t changed since my last answer. Also, the value is likely inaccurate because you’re running that script on the gateway, and therefore returning the value that process will return on the gateway, not the actual client device’s battery.
The only way to execute arbitrary code on the frontend in Perspective is by creating a custom module. That’s a deliberate decision.

2 Likes