Does Samba show tablet battery life?

I was curious to know if samba is capable of been able to read tablet battery life and have it displayed where the date and time is. Or somewhere where its visible so we could potentially watch the life of battery to know when to put it on charging dock .

Is this possible?

Nope. Might be able to put something together using Update Application Title Action and Powershell ?

https://gallery.technet.microsoft.com/scriptcenter/d89ae2e2-bc73-4647-96a1-b6fee5c92e9a

$strComputer = "." 
 
$colItems = get-wmiobject -class "Win32_Battery" -namespace "root\CIMV2" -computername $strComputer 
 
foreach ($objItem in $colItems) { 
      write-host "Availability: " $objItem.Availability 
      write-host "Battery Recharge Time: " $objItem.BatteryRechargeTime 
      write-host "Battery Status: " $objItem.BatteryStatus 
      write-host "Caption: " $objItem.Caption 
      write-host "Chemistry: " $objItem.Chemistry 
      write-host "Configuration Manager Error Code: " $objItem.ConfigManagerErrorCode 
      write-host "Configuration Manager User Configuration: " $objItem.ConfigManagerUserConfig 
      write-host "Creation Class Name: " $objItem.CreationClassName 
      write-host "Description: " $objItem.Description 
      write-host "Design Capacity: " $objItem.DesignCapacity 
      write-host "Design Voltage: " $objItem.DesignVoltage 
      write-host "Device ID: " $objItem.DeviceID 
      write-host "Error Cleared: " $objItem.ErrorCleared 
      write-host "Error Description: " $objItem.ErrorDescription 
      write-host "Estimated Charge Remaining: " $objItem.EstimatedChargeRemaining 
      write-host "Estimated Run Time: " $objItem.EstimatedRunTime 
      write-host "Expected Battery Life: " $objItem.ExpectedBatteryLife 
      write-host "Expected Life: " $objItem.ExpectedLife 
      write-host "Full Charge Capacity: " $objItem.FullChargeCapacity 
      write-host "Installation Date: " $objItem.InstallDate 
      write-host "Last Error Code: " $objItem.LastErrorCode 
      write-host "Maximum Recharge Time: " $objItem.MaxRechargeTime 
      write-host "Name: " $objItem.Name 
      write-host "PNP Device ID: " $objItem.PNPDeviceID 
      write-host "Power Management Capabilities: " $objItem.PowerManagementCapabilities 
      write-host "Power Management Supported: " $objItem.PowerManagementSupported 
      write-host "Smart Battery Version: " $objItem.SmartBatteryVersion 
      write-host "Status: " $objItem.Status 
      write-host "Status Information: " $objItem.StatusInfo 
      write-host "System Creation Class Name: " $objItem.SystemCreationClassName 
      write-host "System Name: " $objItem.SystemName 
      write-host "Time On Battery: " $objItem.TimeOnBattery 
      write-host "Time To Full Charge: " $objItem.TimeToFullCharge 
      write-host 
}


Nice…

2 Likes

##Make a Powershell Script …

battlev.ps1

return (Get-WMIObject Win32_Battery -ea 0).EstimatedChargeRemaining

##Make a BAT file…

battery.bat

@echo off
D:
CD D:\Programs\POS

for /f "delims=" %%a in ('powershell -executionpolicy bypass -File .\battlev.ps1') do Set "errorlevel=%%a"

exit %errorlevel%

##Make a JScript function …

Handler: pshell

function batt() {
  var batFile = "D:\\Programs\\POS\\battery.bat";

  var r = file.For(batFile).Starter().Hidden.ShellExecute();
  
  return r;
}

##Create Action to store value …

##BATT Store Level [Update Program Setting] (Action)##

Action Name: BATT Store Level
Action Type: Update Program Setting
###Parameters:###
Setting Name: [:settingName]
Setting Value: [:settingValue]
Update Type: Update
Is Local: True

##Create Action to Execute Automation Command…

##BATT ExecAMC [Execute Automation Command] (Action)##

Action Name: BATT ExecAMC
Action Type: Execute Automation Command
###Parameters:###
Automation Command Name: [:AMCname]
Command Value: [:AMCvalue]
Background: [:runBG]
Delay: [:delay]

##Create Action to update Application Subtitle …

##AST Update Application Subtitle [Update Application Subtitle] (Action)##

Action Name: AST Update Application Subtitle
Action Type: Update Application Subtitle
###Parameters:###
Title Location: Shell Header
Title: [:content]
Background: [:bg]
Height: [:height]
Refresh Asnyc: [:refreshAsync]

##Create a Trigger …


##Rule to handle Trigger …

##BATT Trigger [Trigger Executed] (Rule)##

Rule Name: BATT Trigger
Event Name: Trigger Executed
Rule Tags:
Custom Constraint List (1):
Execute Rule if: Matches
Trigger Name Equals BATT Trigger

##Actions (1):##

BATT ExecAMC

Constraint: (none)

AMCname: BATT Update
AMCvalue:
runBG: True
delay: 0

##Mappings##

Mappings

Terminal User Role Department Ticket Type

##Rule to handle Automation Command and update Subtitle …

##BATT Update [Automation Command Executed] (Rule)##

Rule Name: BATT Update
Event Name: Automation Command Executed
Rule Tags:
Custom Constraint List (1):
Execute Rule if: Matches
Automation Command Name Equals BATT Update

##Actions (2):##

BATT Store Level

Constraint: (none)

settingName: BatteryLevel
settingValue: {CALL:pshell.batt()}

AST Update Application Subtitle

Constraint: (none)

content:
(see below)
bg:
height:
refreshAsync:

content:

<size 18><font Consolas><color Yellow>BATT:{SETTING:BatteryLevel}%</color></font></size>

##Mappings##

Mappings

Terminal User Role Department Ticket Type

6 Likes

Amazing work as usual bro. This should be in a tutorial :wink:

Will bookmark that for when we get our tablets up and running :wink:

A small tip to execute powershell scripts…

function test(){
  var m = host.lib("System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
  var ps = m.System.Management.Automation.PowerShell.Create();
  ps.AddScript("return (Get-WMIObject Win32_Battery -ea 0).EstimatedChargeRemaining");
  var result = ps.Invoke();
  var result1= result[0];
  ps.Dispose();
  return result1;
}
2 Likes

Is that a new Helper @emre ?

I was going to ask about hooking System.Management to query WMI, to avoid PShell altogether, but could not get it to work. Here is a topic I read on that…

http://stackoverflow.com/questions/8945986/find-out-battery-status-in-c-sharp-or-net

Or another way via System.Windows.Forms.SystemInformation.PowerStatus.BatteryLifePercent …

There are two ways to do it depending on usage.

function test(){
  var m = host.lib("System.Windows.Forms");
  var p = m.System.Windows.Forms.SystemInformation.PowerStatus;
  return p.BatteryLifePercent;
}

function test2(){
  var m = host.type("System.Windows.Forms.SystemInformation","System.Windows.Forms");
  return m.PowerStatus.BatteryLifePercent;
}
1 Like

Thanks for that @emre. Care to explain in layman’s terms, the difference between:

host.type()

and

host.lib()

… so that I can add explanations to the Helper/API document that I started work on.

1 Like

host.lib is a reference to a .net assembly.
host.type is a reference to a C# type.

There is not strict difference for that sample. host.type will work for most cases but host.lib will be useful if we need to access multiple assemblies.

As PowerShell installed separately it is not part of default .net framework. I had to use host.lib to be able to reference the required assembly.

1 Like

With our new insight into hooking SystemInformation is JScript, this simplifies the setup greatly, which what I was originally hoping to achieve.

##JScript

Either of these functions should do the job - just pick one …

##NET [net] (Script)##

Script Name: NET
Script Handler: net

Script:

function battLevel(){
  var m = host.lib("System.Windows.Forms");
  var p = m.System.Windows.Forms.SystemInformation.PowerStatus;
  return (p.BatteryLifePercent * 100).toFixed(0);
}

function battLevel2(){
  var m = host.type("System.Windows.Forms.SystemInformation","System.Windows.Forms");
  return (m.PowerStatus.BatteryLifePercent * 100).toFixed(0);
}

##Trigger to control frequency of Battery Level check

Choose 1 of these, or make your own.


##Action to store Battery Level

##BATT Store Level [Update Program Setting] (Action)##

Action Name: BATT Store Level
Action Type: Update Program Setting
###Parameters:###
Setting Name: [:settingName]
Setting Value: [:settingValue]
Update Type: Update
Is Local: True

##Action to Execute Automation Command

We need this so we can run the JScript as a background Task.

##BATT ExecAMC [Execute Automation Command] (Action)##

Action Name: BATT ExecAMC
Action Type: Execute Automation Command
###Parameters:###
Automation Command Name: [:AMCname]
Command Value: [:AMCvalue]
Background: [:runBG]
Delay: [:delay]

##Action to update Application Subtitle …

##AST Update Application Subtitle [Update Application Subtitle] (Action)##

Action Name: AST Update Application Subtitle
Action Type: Update Application Subtitle
###Parameters:###
Title Location: Shell Header
Title: [:content]
Background: [:bg]
Height: [:height]
Refresh Asnyc: [:refreshAsync]

##Rule to capture Trigger

##BATT Trigger [Trigger Executed] (Rule)##

Rule Name: BATT Trigger
Event Name: Trigger Executed
Rule Tags:
Custom Constraint List (1):
Execute Rule if: Matches
Trigger Name Equals BATT Trigger

##Actions (1):##

BATT ExecAMC

Constraint: (none)

AMCname: BATT Update
AMCvalue:
runBG: True
delay: 0

##Mappings##

Terminal User Role Department Ticket Type
* * * *

##Rule to handle Automation Command and update Subtitle …

##BATT Update [Automation Command Executed] (Rule)##

Rule Name: BATT Update
Event Name: Automation Command Executed
Rule Tags:
Custom Constraint List (1):
Execute Rule if: Matches
Automation Command Name Equals BATT Update

##Actions (2):##

BATT Store Level

Constraint: (none)

settingName: BatteryLevel
settingValue: {CALL:pshell.batt()}

AST Update Application Subtitle

Constraint: (none)

content:
(see below)
bg:
height:
refreshAsync:

content:

<size 18><font Consolas><color Yellow>BATT:{SETTING:BatteryLevel}%</color></font></size>

##Mappings##

Terminal User Role Department Ticket Type
* * * *

Know its not a major think but anyone else think this would be a nice thing to have built in?
Dont know about others but I have found shell/ticket header can become very complex when jugling multiple parts.

Would be nice touch to have a battery meter and maybe also a wifi strength bar built in the header (well with an option to show so can be disabled - probably by default for static terminals)

That way it could be updated on screen change/login etc without interfering with existing/other shell headers.

Perhaps if there is a comparability/customization concern maybe the page with the option could have a box for the code which could be tweaked/customized (a bit like default work period report)

1 Like

Looks pretty good!!

It would be nice to get the wifi signal strength in there as well. Were going to be using surface go tablets for table side orders. They are actually really fast!

1 Like

Does SambaPOS install on surface go? I thought those were the arm based tablets not full windows.

You do not want to check out the mobile order taking app?

Nah those are using Intel Pentium Gold Processors 4415Y They are running windows 10 S mode which only allows windows store apps to be installed but it can be converted to windows 10 home edition for free. Got samba installed and it runs great on it!.. I do have some ubiquiti access points blasting 5ghz wifi so they have plenty of speed for connecting to the server.

I found this online… but not sure if it would work for reporting the signal strength… https://docs.microsoft.com/en-us/previous-versions/windows/desktop/sidebar/system-network-wireless-signalstrength#examples

I just would like to understand what about the mobile app did you not like for table side ordering?

I dont have it on me now but the menu is really big and really complex with time based menus and if i remember right when i was playing with the the layout of all the order tags was not flowing the way we want.

Understood. So we can improve mobile app it would be great if you could share in a PM with me your database. Mobile app is very fast and does not require a concurrent db connection so naturally we would prefer for people to use it. I would love to look at your specific case and see if there are ways we could improve it to meet more use case scenarios.