Virtual Sensors

Virtual sensors are properties on a tracker that can be defined by the user. You can configure these properties as a formula. These properties will then be visible in FleetManagement on the real-time state view but also can be configured to be included in a trigger configuration.

Configuring a Virtual Sensor:

As per the screenshot below, to configure a Virtual Sensor, you need to go to the settings page of the tracker. In this example there are 3 virtual sensors configured. Under the Sensor section, you can define the name of your Virtual Sensor. In the configuration you can enter the formula, the format and properties will be documented below. Finally under Output, you can select the optional output type. This is required to include a Virtual sensor in a Trigger configuration, because the Virtual Sensor will be matched based on this option.

Defining a Virtual Sensor formula:

The formula you can add in the configuration for a Virtual Sensor needs to abide by several rules and includes several operators and input variables.

The first and foremost rule is that the outcome of the formula needs to be interpretable as a Boolean. This means the formula must result in either a True / False or 1 / 0 outcome. The following operators are available:

OperatorDescription
&&Logical AND (condition A and condition B have to be true)
||Logical OR (condition A or condition B has to be true)
==Equals (value on the left has to match the value on the right)
!=Not Equals (value on the left has to be different from the value on the right)
>Greater Than (value on the left has to be greater than the value on the right)
<Lesser Than (value on the left has to be smaller than the value on the right)
>=Greater or Equal to (value on the left has to be greater or equal to the value on the right)
<=Less or Equal to (value on the left has to be smaller or equal to the value on the right)

In this formula the DeviceState (meaning the properties of the current device state) object is used as input. You can use any of the properties described below in this formula:

Property NameProperty Description
CurrentPosition.LatitudeThe latitude of the current position
CurrentPosition.LongitudeThe longitude of the current position
CurrentPosition.UpdateTimestampThe timestamp for the current position data
CurrentPosition.SpeedThe speed at the current position
CurrentPosition.HeadingThe heading (direction) at the current position
CurrentPosition.AltitudeThe altitude at the current position
CurrentPosition.RadiusInMetersThe radius (uncertainty) of the current position in meters
CurrentPosition.HdopThe horizontal dilution of precision for the current position
CurrentPosition.VdopThe vertical dilution of precision for the current position
CurrentPosition.PdopThe positional dilution of precision for the current position
CurrentPosition.SatelllitesThe number of satellites used to determine the current position
Odometer.GpsOdometerThe odometer reading based on GPS data
Odometer.CanBusOdometerThe odometer reading from the CAN bus
Odometer.UpdateTimestampThe timestamp for the odometer data
Temperature1.TemperatureInCelciusThe temperature in degrees Celsius for temperature sensor 1
Temperature1.UpdateTimestampThe timestamp for the temperature data from sensor 1
Temperature2.TemperatureInCelciusThe temperature in degrees Celsius for temperature sensor 2
Temperature2.UpdateTimestampThe timestamp for the temperature data from sensor 2
Temperature3.TemperatureInCelciusThe temperature in degrees Celsius for temperature sensor 3
Temperature3.UpdateTimestampThe timestamp for the temperature data from sensor 3
Temperature4.TemperatureInCelciusThe temperature in degrees Celsius for temperature sensor 4
Temperature4.UpdateTimestampThe timestamp for the temperature data from sensor 4
Humidity1.HumidityInPercentThe humidity in percent for humidity sensor 1
Humidity1.UpdateTimestampThe timestamp for the humidity data from sensor 1
Humidity2.HumidityInPercentThe humidity in percent for humidity sensor 2
Humidity2.UpdateTimestampThe timestamp for the humidity data from sensor 2
TotalAxleWeight.TotalWeightInKgThe total weight in kilograms for all the axles
TotalAxleWeight.UpdateTimestampThe timestamp for the total axle weight data
TotalAxleWeight.AverageWeightInKgThe average weight in kilograms per axle
Fuel.FuelLevelInPercentageThe fuel level in percentage
Fuel.FuelLevelRawThe raw fuel level data
Fuel.UpdateTimestampThe timestamp for the fuel data
Fuel1.FuelLevelInPercentageThe fuel level in percentage
Fuel1.FuelLevelRawThe raw fuel level data
Fuel1.UpdateTimestampThe timestamp for the fuel data
Fuel2.FuelLevelInPercentageThe fuel level in percentage
Fuel2.FuelLevelRawThe raw fuel level data
Fuel2.UpdateTimestampThe timestamp for the fuel data
Ignition.StateThe current state of the ignition
Ignition.UpdateTimestampThe timestamp for the ignition data
ExternalPower.StateThe current state of the external power
ExternalPower.UpdateTimestampThe timestamp for the external power data
Input1.StateThe current state of input 1
Input1.UpdateTimestampThe timestamp for the input 1 data
Input2.StateThe current state of input 2
Input2.UpdateTimestampThe timestamp for the input 2 data
Input3.StateThe current state of input 3
Input3.UpdateTimestampThe timestamp for the input 3 data
Input4.StateThe current state of input 4
Input4.UpdateTimestampThe timestamp for the input 4 data
Input5.StateThe current state of input 5
Input5.UpdateTimestampThe timestamp for the input 5 data
Input6.StateThe current state of input 6
Input6.UpdateTimestampThe timestamp for the input 6 data
Output1.StateThe current state of output 1
Output1.UpdateTimestampThe timestamp for the output 1 data
Output2.StateThe current state of output 2
Output2.UpdateTimestampThe timestamp for the output 2 data
Output3.StateThe current state of output 3
Output3.UpdateTimestampThe timestamp for the output 3 data
Output4.StateThe current state of output 4
Output4.UpdateTimestampThe timestamp for the output 4 data
Analog1.ValueThe value of analog input 1
Analog1.UpdateTimestampThe timestamp for the analog input 1 data
Analog2.ValueThe value of analog input 2
Analog2.UpdateTimestampThe timestamp for the analog input 2 data
ExternalBattery.BatteryLevelInVoltageThe battery level in voltage for the external battery
ExternalBattery.UpdateTimestampThe timestamp for the external battery data
BackupBattery.BatteryLevelInVoltageThe battery level in voltage for the backup battery
BackupBattery.UpdateTimestampThe timestamp for the backup battery data
CommunicationStatus.LocationTypeThe type of location
CommunicationStatus.EventTypeThe type of event
CommunicationStatus.MessageSequenceNumberThe message sequence number
CommunicationStatus.UpdateTimestampThe timestamp for when the data was updated
CommunicationStatus.ServerTimestampThe timestamp for when the data was received by the server
CommunicationStatus.IsRoamingIndicates whether the device is roaming
DriverIdTagStatus.TagThe tag value
DriverIdTagStatus.UpdateTimestampThe timestamp for when the data was updated
TagScanStatus.TagThe tag value
TagScanStatus.UpdateTimestampThe timestamp for when the data was updated
RpmStatus.RpmThe RPM value
RpmStatus.UpdateTimestampThe timestamp for when the data was updated
DeviceActivityStatus.DlpDeviceStateThe device state
DeviceActivityStatus.UpdateTimestampThe timestamp for when the data was updated
BatteryConsumptionState.BatteryChargeStateIndicates whether the battery is charging
BatteryConsumptionState .BatteryChargeLevelInPercentageThe battery charge level in percentage
BatteryConsumptionState .BatteryPowerConsumptionInKWhPer100KmThe battery power consumption in KWh per 100 km
BatteryConsumptionState .RemainingDistanceInKmThe remaining distance in km
BatteryConsumptionState .UpdateTimestampThe timestamp for when the data was updated
FuelConsumptionState.FuelConsumedThe amount of fuel consumed
FuelConsumptionState.RemainingDistanceInKmThe remaining distance in km
FuelConsumptionState.UpdateTimestampThe timestamp for when the data was updated
Angle1.AngleInDegreesThe angle in degrees
Angle1.UpdateTimestampThe timestamp for when the data was updated
Angle2.AngleInDegreesThe angle in degrees
Angle2.UpdateTimestampThe timestamp for when the data was updated
Angle3.AngleInDegreesThe angle in degrees
Angle3.UpdateTimestampThe timestamp for when the data was updated
Angle4.AngleInDegreesThe angle in degrees
Angle4.UpdateTimestampThe timestamp for when the data was updated
BleBatteryState1.BatteryLevelPercentageThe battery level percentage for a bluetooth ble sensor
BleBatteryState1.UpdateTimestampThe timestamp for when the data was updated
BleBatteryState2.BatteryLevelPercentageThe battery level percentage for a bluetooth ble sensor
BleBatteryState2.UpdateTimestampThe timestamp for when the data was updated
BleBatteryState3.BatteryLevelPercentageThe battery level percentage for a bluetooth ble sensor
BleBatteryState3.UpdateTimestampThe timestamp for when the data was updated
BleBatteryState4.BatteryLevelPercentageThe battery level percentage for a bluetooth ble sensor
BleBatteryState4.UpdateTimestampThe timestamp for when the data was updated
AccelerometerState.AccelerationForceThe acceleration force
AccelerometerState.BrakingForceThe braking force
AccelerometerState.CorneringForceThe cornering force
AccelerometerState.UpdateTimestampThe timestamp for when the data was updated

Along with these properties you can use certain built in functions to add some more advanced functionality to the formula. One of these examples is DateTime.UtcNow which retrieves the current date and time in UTC. Since all the UpdateTimestamps are also in UTC, this is usefull to compare against. On the DateTime.UtcNow you have the option to add several modifiers to change the date. These modifiers are AddDays(n) with n being the negative or positive amount of days to add, Add Hours(n) with n being the negative or positive amount of hours to add or AddMinutes(n) with n being the negative or positive amount of minutes to add.

An example function using this capability would be:

Ignition.State && (ExternalBattery.UpdateTimestamp >= DateTime.UtcNow.AddDays(-1) ? (ExternalBattery.BatteryLevelInVoltage > 24) : true)

This example would return true when the device has Ignition.State = true but also has a ExternalBattery value that is at least newer than this time yesterday and has a BatteryLevelInVoltage higher than 24 volt.

Please also feel free to contact us for more complex rules and we can work with you to devise a formula to calculate this property.

Updated on January 5, 2023

Related Articles

Leave a Comment