Skip to content

KWGT KustomWidget Support

Michael Balzer edited this page Dec 25, 2022 · 2 revisions

KWGT KustomWidget Support

Beginning with release 4.0.0, the OVMS App supports the "KWGT" custom widget framework by Kustom Industries.

KWGT allows to build your own application widgets. It's similar to Automagic, but actively maintained and also working on newer Android releases.

Access Car Status Data

The OVMS App sends all variables of the Update Broadcast Intent data to KWGT using the ID ovms, with some specifal handling for arrays as described there. Within KWGT, OVMS variables can be accessed by the KWGT broadcast receiver function br().

  • br(ovms, <varname>)

This can be used to directly display values, to control graphical element properties, or to trigger other actions.

To be able to permanently receive and process data from your vehicle, enable the OVMS App's background connection mode from the options menu. You also should disable Android's battery optimization for the App: set the App to "unrestricted" battery usage from the Android App battery settings, so Android won't aggressively stop background operations.

Execute Commands

To execute a command from KWGT, you need to define the command as a stored command within the OVMS App first:

  1. Open the notifications page
  2. Click on the bookmarks icon in the menu pane
  3. Click the plus icon, insert a description (for you) and the actual command, e.g. charge start, save the command

To invoke a stored command from KWGT:

  1. Add some kind of "button" element to a widget (e.g. a rectangle)
  2. Set the touch event for the element to "launch shortcut"
  3. Select the shortcut to launch

Note: the command shortcut doesn't need to be pinned to the desktop.

If enabled, the command result broadcast (see Command Execution via Broadcast Intent) is also sent to KWGT. Be aware command results will come asynchronously and may mix with results from other commands being executed, so you need to verify the response is the expected by checking the variables.

Example Widget: SOC Gauge

The example widget displays the current SOC level as a 120° analog gauge and the charging status by a small battery icon below the gauge.

KWGT SOC Gauge

  • Download widget definition: SOC_Gauge_1.kwgt.zip
    • Note: to import the widget definition into KWGT, you need to remove the .zip extension after downloading to your device.

The analog gauge is created from an SVG for the scale (created using the Inkscape Knob Scale Generator plugin by Artyom Sinitsin) and a red rounded rectangle for the pointer.

The pointer rotation is calculated from the SOC level by this simple formula:

$br(ovms, car_soc)/100*120-60$

This scales car_soc to 120° and rotates the result left by 60° to match the scale.

The icon formula uses the KWGT if() function to translate the charge port status into a standard icon name:

$if(br(ovms,car_chargeport_open) = true, "Battery_charging_full", "Battery_std")$