WolkAbout IoT Platform Library¶
WolkAbout IoT Platform is an IoT application enablement platform that allows users to easily and securely connect, manage, monitor and control disparate devices, transform real-time readings into meaningful data and combine different devices and services into a complete IoT solution: WolkAbout IoT Platform
Device¶
The Device
class contains all the required information for connecting
to the WolkAbout IoT Platform.
-
Device
(key, password, actuator_references=None)¶
key
- The device key obtained when creating the device on WolkAbout IoT platformpassword
- The device password obtained when creating the device on WolkAbout IoT platformactuator_references
- A list of actuator references defined in the device type on WolkAbout IoT Platform
Wolk¶
The Wolk
class wraps all the functionality of the library.
-
Wolk
(device, host="api-demo.wolkabout.com", port=2883, actuation_handler=None, actuator_status_provider=None, configuration_handler=None, configuration_provider=None, message_queue_size=100, keep_alive_enabled=True)¶
device
: Device containing key, password and actuator referenceshost
: Address of the MQTT broker of the Platform - defaults to demo instanceport
: Port of the MQTT broker - defaults to demo instance’s portactuation_handler
: Actuation handler function, optional-
actuation_handler
(reference, value)¶
Implement this function in order to execute actuation commands issued from the Platform.
This function will try to set the actuator, identified by
reference
, to thevalue
specified by the Platform.-
actuator_status_provider
: Actuator status provider function, optional-
actuator_status_provider
(reference)¶
Implement this function in order to provide information about the current status of the actuator to the Platform.
This function will return the current actuator
state
andvalue
, identified byreference
, to the Platform.The possible states are:
iot.ACTUATOR_STATE_READY iot.ACTUATOR_STATE_BUSY iot.ACTUATOR_STATE_ERROR
The method should return something like this:
return (iot.ACTUATOR_STATE_READY, value)
-
configuration_handler
: Configuration handler function, optional-
configuration_handler
(configuration)¶
Implement this function in order to handle configuration commands issued from the Platform.
This function should update device configuration with received configuration values.
configuration
- Dictionary that contains reference:value pairs
-
configuration_provider
: Configuration provider function, optional-
configuration_provider
()¶
Implement this function to provide information about the current configuration settings to the Platform.
Reads current device configuration and returns it as a dictionary with device configuration reference as the key, and device configuration value as the value.
-
message_queue_size
: Number of reading to store in memory, defaults to 100keep_alive_enabled
: Periodically publish keep alive message, default True
-
Wolk.
connect
()¶
Connect to the Platform.
-
Wolk.
disconnect
()¶
Disconnect from the Platform.
-
Wolk.
add_sensor_reading
(reference, value, timestamp=None)¶
Add a sensor reading into storage.
reference
: The reference of the sensorvalue
: The value of the sensor readingtimestamp
: (optional) Unix timestamp - if not provided, Platform will assign one
-
Wolk.
add_alarm
(reference, active, timestamp=None)¶
Add an alarm event into storage.
reference
: The reference of the alarmactive
: Current state of the alarmtimestamp
: (optional) Unix timestamp - if not provided, Platform will assign one
-
Wolk.
publish
()¶
Publish all currently stored messages to the Platform.
-
Wolk.
publish_actuator_status
(reference)¶
Publish the current actuator status to the Platform.
reference
The reference of the actuator
-
Wolk.
publish_configuration
()¶
Publish the current device configuration to the Platform.
-
Wolk.
request_timestamp
()¶
Return last received Platform timestamp.
If keep alive service is not enabled, this will always be None.
return: | UTC timestamp in milliseconds or None |
---|---|
rtype: | int, None |