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: Union[wolk_gateway_module.model.reading_type_name.ReadingTypeName, str] = None, unit: Union[wolk_gateway_module.model.reading_type_measurement_unit.ReadingTypeMeasurementUnit, str] = None, description: Optional[str] = None)[source]¶ Sensor template for registering device on Platform.
Variables: - description (str or None) – Description detailing this sensor
- 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: Union[wolk_gateway_module.model.reading_type_name.ReadingTypeName, str] = None, unit: Union[wolk_gateway_module.model.reading_type_measurement_unit.ReadingTypeMeasurementUnit, str] = None, description: Optional[str] = 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 inReadingTypeName
andReadingTypeMeasurementUnit
.Custom reading types that have been previously defined on WolkAbout IoT Platform can be used by passing string values for
reading_type_name
andunit
.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
-
class
wolk_gateway_module.model.data_type.
DataType
[source]¶ Use to create a generic reading type.
Variables:
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 inReadingTypeName
andReadingTypeMeasurementUnit
.Custom reading types can be used by passing string values for the name and measurement unit.
Variables: - name (Union[ReadingTypeName, str]) – Name of reading type
- unit (Union[ReadingTypeMeasurementUnit, str]) – Measurement unit of reading type
-
__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
Alarms¶
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)[source]¶ Actuator template for registering device on Platform.
Variables: -
__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)[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 usereading_type_name
andunit
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
-
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)[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
- 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)[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
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: - actuators (List[ActuatorTemplate]) – List of actuators on device
- alarms (List[AlarmTemplate]) – List of alarms on device
- configurations (List[ConfigurationTemplate]) – List of configurations on device
- connectivity_parameters (Dict[str, Union[str, int, float, bool]]) – Device’s connectivity parameters
- supports_firmware_update (bool) – Is firmware update enabled for this device
- sensors (List[SensorTemplate]) – List of sensors on device
- type_parameters (Dict[str, Union[str, int, float, bool]]) – Device’s type parameters
- firmware_update_parameters (Dict[str, Union[str, int, float, bool]]) – Device’s firmware update parameters
-
__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]