This guide provides examples for creating a new JSON configuration including user interaction, devices and device items.
User interaction configuration
There is a UserInteraction file in tee/sa/configs/com.prosyst.mbs.test.templates.device.items/UserInteractions directory.
When runUserInteracionActions attribute is set to true the Device Item Configuration, that contains userInteraction action, expects a corresponding action from the user, when set to false — it is skipped.
Device configuration
For each device configuration, there is a matching object which contains an attribute or attributes of the device. The attributes are selected for particular device type. As an example, each 4-noks device contains attribute hardware.vendor: 4-noks.
"matching": {
"hardware.vendor": "4-noks"
}
Manages which devices get tested in the system. If skipThisDevice is set to TRUE, the device is not tested, it is skipped.
"skipThisDevice": true
Each attribute consists of a key and a value. If the value is dynamic, it is marked with "*". For example:
"name": null,
"tags": [],
"attributes": {
"firmware.version": "*",
"hardware.version": "*",
"connection.pan.id": "*",
"adapter.name": "ZigBee",
"factory.uid": "da:device:admin",
"connection.friendly.name": "*",
"controller.id": "*",
"firmware.vendor": "4-noks",
"serial.number": "*",
"connection.comm.port": "*",
"connection.channel": "*",
"connection.baud.rate": "*",
"hardware.vendor": "4-noks",
"nwk.address": "*",
"primary.power.source": "Mains (single phase)",
"adapter.version": "*",
"model": "Plug",
"ieee.address": "*"
},
"status": "ONLINE"
Each Device has a set of Device Items. They are described in a list. Their sequence defines the execution order.
"items": [
{
"objectClass": "com.prosyst.mbs.services.da.items.Sensor",
"run": true,
"itemMatchingAttributes": {
"da.quantity": "com.prosyst.mbs.services.units.quantity.Power"
},
"tags": [],
"attributes": {
"firmware.version": "*",
"connection.pan.id": "*",
"input.clusters": "*",
"da.quantity": "com.prosyst.mbs.services.units.quantity.Power",
"da.sensor.medium": "electricity",
"connection.friendly.name": "*",
"active.endpoint": "*",
"profile.id": "*",
"device.uid": "*",
"controller.id": "*",
"firmware.vendor": "4-noks",
"device.id": "*",
"profile.name": "Home Automation",
"serial.number": "*",
"connection.comm.port": "*",
"connection.channel": "*",
"connection.baud.rate": "*",
"device.name": "Mains Power Outlet",
"nwk.address": "*",
"primary.power.source": "Mains (single phase)",
"model": "Plug",
"ieee.address": "*"
}
]
Contains device item interface.
"objectClass": "com.prosyst.mbs.services.da.items.TransitionActuator"
Describes configurable tests.
"jsonFileName": "TransitionActuatorDimensionless.json"
When set to true the device item is executed. When set to false, it is skipped.
"run": true
When a device has a set of several identical Device Items, they are distinguished by specific attributes. When these functionalities have to be distinguished, a new object is added to the JSON configuration – itemMatchingAttributes, in which the relevant attribute is included.
"itemMatchingAttributes": {
"da.quantity": "com.prosyst.mbs.services.units.quantity.Dimensionless"
}
For item's attributes, the rules are the same as for the attributes of the device. If the name is dynamic it is indicated with "*".
If runAllTest is set to true, the run value is ignored, but all device items are executed. If runAllTest is false, the run value is considered and if it is true, the relevant item is executed.
"runAllTests": false
Device Item configuration
Before you create the JSON file, check the availability of the Device Item functionalities.
Some devices contain only one item. Put this item first In device JSON file. This is necessary to call an item's operation to activate the remaining additional items contained. The described behavior is characteristic for Bluetooth devices.
The default timeout of 1s is added in case it is not provided from JSON file configuration.
"objectClass": "com.prosyst.mbs.services.da.items.Switch"
In JSON file you can include actions — invokeOperation, setProperty, getProperty and userInteraction. Here is a JSON Example Representation:
"actions": [
{
"action": "invokeOperation",
"name": "off",
"events": [
{
"event.topics": "com/prosyst/mbs/services/fim/FunctionalItemEvent/PROPERTY_CHANGED",
"property.name": "on",
"property.value.new": false,
"property.value.old": true
}
],
"init": true,
"timeout": 10000
}
{
"action": "setProperty",
"name": "value",
"arguments": [
{
"unit": {
"symbol": "℃",
"systemName": "SI"
},
"value": {
"value": "7.0",
"className": null
}
}
],
"events": [
{
"event.topics": "com/prosyst/mbs/services/fim/FunctionalItemEvent/PROPERTY_CHANGED",
"property.name": "value",
"property.value.new": {
"unit": {
"symbol": "℃",
"systemName": "SI"
},
"value": {
"value": "7.0"
}
}
}
],
"timeout": 60000
},
{
"action": "getProperty",
"name": "value",
"result": {
"unit": {
"symbol": "℃",
"systemName": "SI"
},
"value": {
"value": "7.0"
}
},
"timeout": 5000
}
Some items like Sensor and Detector can throw events without any operation executed or setting changed. These are events as change of temperature, humidity, etc which occur naturally without interaction.
For this reason, "waitEvents" action is provided:
"actions": [
{
"action": "waitEvents",
"name": "value",
"events": [
{
"event.topics": "com/prosyst/mbs/services/fim/FunctionalItemEvent/PROPERTY_CHANGED",
"property.name": "value"
],
"timeout": 300000
}
}
Invoking such operations or setting certain properties of Device Items may reflect on the values of other Device Items. If this dependence between Device Items is to be reflected in the test, create a new configuration in the tee/sa/configs/com.prosyst.mbs.test.templates.device.items/ItemConfigs directory.
Performing an "on" operation of item Switch for a particular device e.g. 4-noks - OnOff Socket with Energy Metering where an appliance is plugged in, results in changing the electrical consumption for the Sensor item.
The example below contains "itemId": "inSensorSwitch". This indicates that the invoking operation "on" reflects the other item Sensor. It is also necessary to put this ID in device JSON file. In this case, it is 4-noks - OnOff Socket with Energy Metering where the concrete Sensor item will generate an event.
{
"objectClass": "com.prosyst.mbs.services.da.items.Switch",
"actions": [
{
"action": "invokeOperation",
"name": "off",
"events": [
{
"event.topics": "com/prosyst/mbs/services/fim/FunctionalItemEvent/PROPERTY_CHANGED",
"property.name": "on",
"property.value.new": false,
"property.value.old": true
}
],
"init": true,
"timeout": 10000
},
{
"action": "invokeOperation",
"name": "on",
"itemId": "inSensorSwitch",
"events": [
{
"event.topics": "com/prosyst/mbs/services/fim/FunctionalItemEvent/PROPERTY_CHANGED",
"property.name": "value",
"property.value.old": {
"value": 0.0,
"unit": {
"symbol": "kW",
"systemName": "SI",
"aliases": [],
"quantityType": "com.prosyst.mbs.services.units.quantity.Power"
}
}
}
],
"timeout": 30000
},
{
"action": "invokeOperation",
"name": "off",
"itemId": "inSensorSwitch",
"events": [
{
"event.topics": "com/prosyst/mbs/services/fim/FunctionalItemEvent/PROPERTY_CHANGED",
"property.name": "value",
"property.value.new": {
"value": 0.0,
"unit": {
"symbol": "kW",
"systemName": "SI",
"aliases": [],
"quantityType": "com.prosyst.mbs.services.units.quantity.Power"
}
}
}
],
"timeout": 30000
}
]
}
This attribute is for redefining of a specific item. If the device is in off mode and off operation of the device is executed, the event is not shown and the test continues to run.
"init": true
This attribute is used for manipulation of the device via user interaction.
{
"objectClass": "com.prosyst.mbs.services.da.items.KeyInput",
"actions": [
{
"action": "userInteraction",
"hint": "Please, press button 1 on the device!",
"events": [
{
"event.topics": "com/prosyst/mbs/services/fim/FunctionalItemEvent/PROPERTY_CHANGED",
"property.name": "event",
"property.value.new": {
"actions": ["PRESSED"],
"keyCode": 1,
"keyName": "1"
}
},
{
"event.topics": "com/prosyst/mbs/services/fim/FunctionalItemEvent/PROPERTY_CHANGED",
"property.name": "event",
"property.value.new": {
"actions": ["RELEASED"],
"keyCode": 1,
"keyName": "1"
}
}
],
"timeout": 15000
}