Battery percentage display

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