Creating devices

Creating devices consists of defining individual templates for each device’s sensor, alarm, actuator and configuration option. All these templates are joined together to create a device template that will contain information about all data the device will yield and will be used to register the device on WolkAbout IoT Platform.

All of these templates have a field named reference that is used to identify that particular source of information. This field needs to be unique per device.

On this page, each of these templates will be disambiguated and finally a device will be created.

The concept behind device templates is similar to classes in object-oriented programming, so it helps to think about them like this:

class -> object == device_template -> device

Where at the end of the process of creating a device, there is an uniquely identifiable object that is then registered on WolkAbout IoT Platform

Sensors

class wolk_gateway_module.model.sensor_template.SensorTemplate(name: str, reference: str, data_type: wolk_gateway_module.model.data_type.DataType = None, reading_type_name: wolk_gateway_module.model.reading_type_name.ReadingTypeName = None, unit: wolk_gateway_module.model.reading_type_measurement_unit.ReadingTypeMeasurementUnit = None, description: Optional[str] = None, minimum: Union[int, float, None] = None, maximum: Union[int, float, None] = None)[source]

Sensor template for registering device on Platform.

Variables:
  • description (str or None) – Description detailing this sensor
  • maximum (int or float or None) – Maximum sensor value
  • minimum (int or float or None) – Minimum sensor value
  • name (str) – Name of sensor
  • reference (str) – Unique sensor reference
  • unit (ReadingType) – Sensor reading type measurement name and unit
__init__(name: str, reference: str, data_type: wolk_gateway_module.model.data_type.DataType = None, reading_type_name: wolk_gateway_module.model.reading_type_name.ReadingTypeName = None, unit: wolk_gateway_module.model.reading_type_measurement_unit.ReadingTypeMeasurementUnit = None, description: Optional[str] = None, minimum: Union[int, float, None] = None, maximum: Union[int, float, None] = None)[source]

Sensor template for device registration request.

Define a reading type for sensors, either a generic type by specifying a DataType (numeric, boolean or string) or entering a predefined one by using the enumerations provided in ReadingTypeName and ReadingTypeMeasurementUnit.

Custom reading types that have been previously defined on WolkAbout IoT Platform can be used by passing string values for reading_type_name and unit.

Parameters:
  • name (str) – Sensor name
  • reference (str) – Sensor reference
  • data_type (Optional[DataType]) – Sensor data type for generic reading type
  • reading_type_name (Optional[Union[ReadingTypeName, str]]) – Reading type name from defined enumeration or string for custom
  • unit (Optional[Union[ReadingTypeMeasurementUnit, str]]) – Reading type measurement unit from defined enumeration or string for custom
  • description (Optional[str]) – Description detailing the sensor’s specification
  • minimum (Optional[Union[int, float]]) – Minimum sensor value
  • maximum (Optional[Union[int, float]]) – Maximum sensor value
to_dto() → Dict[str, Union[int, float, str]][source]

Create data transfer object used for registration.

Returns:dto
Return type:Dict[str, Union[str, int, float]]
class wolk_gateway_module.model.data_type.DataType[source]

Use to create a generic reading type.

Variables:
  • BOOLEAN (int) – Generic boolean reading type
  • NUMERIC (int) – Generic numeric reading type
  • STRING (int) – Generic string reading type

Reading types

class wolk_gateway_module.model.reading_type.ReadingType(data_type: Optional[wolk_gateway_module.model.data_type.DataType] = None, name: Union[wolk_gateway_module.model.reading_type_name.ReadingTypeName, str, None] = None, unit: Union[wolk_gateway_module.model.reading_type_measurement_unit.ReadingTypeMeasurementUnit, str, None] = None)[source]

Reading type used for registering sensors on WolkAbout IoT Platform.

Define a reading type for sensors, either a generic type by specifying a DataType (numeric, boolean or string) or entering a predefined one by using the enumerations provided in ReadingTypeName and ReadingTypeMeasurementUnit .

Custom reading types can be used by passing string values for the name and measurement unit.

Variables:
__init__(data_type: Optional[wolk_gateway_module.model.data_type.DataType] = None, name: Union[wolk_gateway_module.model.reading_type_name.ReadingTypeName, str, None] = None, unit: Union[wolk_gateway_module.model.reading_type_measurement_unit.ReadingTypeMeasurementUnit, str, None] = None)[source]

Reading type used for registering device’s sensors.

Parameters:
  • data_type (Optional[DataType]) – Data type for generic reading type
  • name (Optional[Union[ReadingTypeName, str]]) – Reading type name from defined enumeration or string for custom
  • unit (Optional[Union[ReadingTypeMeasurementUnit, str]]) – Reading type measurement unit from defined enumeration or string for custom
Raises:

ValueError – Unable to create a reading type from given input

To view all available reading type names, view source

class wolk_gateway_module.model.reading_type_name.ReadingTypeName[source]

Enumeration of defined reading type names on WolkAbout IoT Platform.

To view all available reading type measurement units and their symbols, view source

class wolk_gateway_module.model.reading_type_measurement_unit.ReadingTypeMeasurementUnit[source]

Enumeration of defined reading type measurement units.

Alarms

class wolk_gateway_module.model.alarm_template.AlarmTemplate(name: str, reference: str, description: Optional[str] = '')[source]

Alarm template for registering device on WolkAbout IoT Platform.

Variables:
  • name (str) – Alarm name
  • reference (str) – Alarm reference
  • description (str) – Alarm description
__init__(name: str, reference: str, description: Optional[str] = '') → None
to_dto() → Dict[str, str][source]

Create data transfer object used for registration.

Returns:dto
Return type:Dict[str, str]

Actuators

class wolk_gateway_module.model.actuator_template.ActuatorTemplate(name: str, reference: str, data_type: wolk_gateway_module.model.data_type.DataType = None, reading_type_name: str = None, unit: str = None, description: str = None, minimum: Union[int, float, None] = None, maximum: Union[int, float, None] = None)[source]

Actuator template for registering device on Platform.

Variables:
  • description (str or None) – Description detailing this actuator
  • maximum (int or float or None) – Maximum actuator value
  • minimum (int of float or None) – Minimum actuator value
  • name (str) – Name of actuator
  • reference (str) – Unique actuator reference
  • unit (dict) – Actuator reading type measurement name and unit
__init__(name: str, reference: str, data_type: wolk_gateway_module.model.data_type.DataType = None, reading_type_name: str = None, unit: str = None, description: str = None, minimum: Union[int, float, None] = None, maximum: Union[int, float, None] = None)[source]

Actuator template for device registration request.

Define a reading type either by using the data_type to select a generic type (boolean, numeric, string) or use reading_type_name and unit to use a custom reading type that was previously defined on WolkAbout IoT Platform.

Parameters:
  • name (str) – Actuator name
  • reference (str) – Actuator reference
  • data_type (Optional[DataType]) – Actuator data type
  • reading_type_name (Optional[str]) – Custom reading type name
  • unit (Optional[str]) – Custom reading type measurement unit
  • description (Optional[str]) – Description detailing the actuator
  • minimum (Optional[Union[int,float]]) – Actuator minimum value
  • maximum (Optional[Union[int,float]]) – Actuator maximum value
to_dto() → Dict[str, Union[int, float, str]][source]

Create data transfer object used for registration.

Returns:dto
Return type:Dict[str, Union[int, float, str]]

Configurations

class wolk_gateway_module.model.configuration_template.ConfigurationTemplate(name: str, reference: str, data_type: wolk_gateway_module.model.data_type.DataType, description: Optional[str] = None, size: int = 1, labels: Optional[List[str]] = None, default_value: Optional[str] = None, minimum: Union[int, float, None] = None, maximum: Union[int, float, None] = None)[source]

Configuration template for registering device on Platform.

Variables:
  • data_type (DataType) – Configuration data type
  • default_value (str or None) – Default value of configuration
  • description (str or None) – Description of configuration
  • labels (List[str] or None) – Labels of fields when data size > 1
  • maximum (int) – Maximum configuration value
  • minimum (int) – Minimum configuration value
  • name (str) – Configuration name
  • reference (str) – Unique configuration reference
  • size (int) – Data size
__init__(name: str, reference: str, data_type: wolk_gateway_module.model.data_type.DataType, description: Optional[str] = None, size: int = 1, labels: Optional[List[str]] = None, default_value: Optional[str] = None, minimum: Union[int, float, None] = None, maximum: Union[int, float, None] = None)[source]

Configuration template for device registration request.

Parameters:
  • name (str) – Configuration name
  • reference (str) – Configuration reference
  • data_type (DataType) – Configuration data type
  • description (Optional[str]) – Configuration description
  • size (Optional[int]) – Configuration data size (max 3)
  • labels (Optional[List[str]]) – List of string lables when data size > 1
  • default_value (Optional[str]) – Default configuration value
  • minimum (Optional[Union[int, float]]) – Minimum configuration value
  • maximum (Optional[Union[int, float]]) – Maximum configuration value
to_dto() → Dict[str, Union[str, int, float, List[str]]][source]

Create data transfer object used for registration.

Returns:dto
Return type:Dict[str, Union[str, int, float, List[str]]]

Device template

class wolk_gateway_module.model.device_template.DeviceTemplate(actuators: List[wolk_gateway_module.model.actuator_template.ActuatorTemplate] = <factory>, alarms: List[wolk_gateway_module.model.alarm_template.AlarmTemplate] = <factory>, configurations: List[wolk_gateway_module.model.configuration_template.ConfigurationTemplate] = <factory>, sensors: List[wolk_gateway_module.model.sensor_template.SensorTemplate] = <factory>, supports_firmware_update: bool = False, type_parameters: Dict[KT, VT] = <factory>, connectivity_parameters: Dict[KT, VT] = <factory>, firmware_update_parameters: Dict[KT, VT] = <factory>)[source]

Contains information required for registering device on Platform.

A device template consists of lists of templates (actuator, alarm, sensor, configuration) that represent what data the device is expected to send and receive. All references of a device must be unique.

Other than data feed templates, there is a supports_firmware_update parameter that specifies if this device has the capability to perform firmware updates.

Finally, there are type, connectivity and firmware update parameters that are dictionaries that will contain more attributes to group together devices, but are unused at this moment.

Variables:
__init__(actuators: List[wolk_gateway_module.model.actuator_template.ActuatorTemplate] = <factory>, alarms: List[wolk_gateway_module.model.alarm_template.AlarmTemplate] = <factory>, configurations: List[wolk_gateway_module.model.configuration_template.ConfigurationTemplate] = <factory>, sensors: List[wolk_gateway_module.model.sensor_template.SensorTemplate] = <factory>, supports_firmware_update: bool = False, type_parameters: Dict[KT, VT] = <factory>, connectivity_parameters: Dict[KT, VT] = <factory>, firmware_update_parameters: Dict[KT, VT] = <factory>) → None

Device

After a device template has been created, now a device can be created from it.

class wolk_gateway_module.model.device.Device(name: str, key: str, template: wolk_gateway_module.model.device_template.DeviceTemplate = <factory>)[source]

Device identified by name and key, as well as its template.

Variables:
  • name (str) – Device’s name
  • key (str) – Device’s unique key
  • template (DeviceTemplate) – Device template that defines data the device will send and receive.
__init__(name: str, key: str, template: wolk_gateway_module.model.device_template.DeviceTemplate = <factory>) → None
get_actuator_references() → List[str][source]

Get list of actuator references for device.

Returns:actuator_references
Return type:List[str]
has_configurations() → bool[source]

Return if device has configuration options.

Returns:has_configurations
Return type:bool
supports_firmware_update() → bool[source]

Return if device supports firmware update.

Returns:supports_firmware_update
Return type:bool