Skip to main content
██╗    ██╗ ██████╗ ██╗     ██╗  ██╗ ██████╗ ██████╗ ███╗   ██╗███╗   ██╗███████╗ ██████╗████████╗
██║    ██║██╔═══██╗██║     ██║ ██╔╝██╔════╝██╔═══██╗████╗  ██║████╗  ██║██╔════╝██╔════╝╚══██╔══╝
██║ █╗ ██║██║   ██║██║     █████╔╝ ██║     ██║   ██║██╔██╗ ██║██╔██╗ ██║█████╗  ██║        ██║
██║███╗██║██║   ██║██║     ██╔═██╗ ██║     ██║   ██║██║╚██╗██║██║╚██╗██║██╔══╝  ██║        ██║
╚███╔███╔╝╚██████╔╝███████╗██║  ██╗╚██████╗╚██████╔╝██║ ╚████║██║ ╚████║███████╗╚██████╗   ██║
 ╚══╝╚══╝  ╚═════╝ ╚══════╝╚═╝  ╚═╝ ╚═════╝ ╚═════╝ ╚═╝  ╚═══╝╚═╝  ╚═══╝╚══════╝ ╚═════╝   ╚═╝

                                           ██████╗ ██╗   ██╗████████╗██╗  ██╗ ██████╗ ███╗   ██╗
                                           ██╔══██╗╚██╗ ██╔╝╚══██╔══╝██║  ██║██╔═══██╗████╗  ██║
                                     █████╗██████╔╝ ╚████╔╝    ██║   ███████║██║   ██║██╔██╗ ██║
                                     ╚════╝██╔═══╝   ╚██╔╝     ██║   ██╔══██║██║   ██║██║╚██╗██║
                                           ██║        ██║      ██║   ██║  ██║╚██████╔╝██║ ╚████║
                                           ╚═╝        ╚═╝      ╚═╝   ╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═══╝

Tests and Coverage PyPI version PyPI - Python Version GitHub Code style: black Checked with mypy Documentation Status

WolkAbout Python Connector library for connecting devices to WolkAbout IoT platform instance.

Prerequisite

  • Python 3.7+

Installation

There are two ways to install this package

Installing with pip

python3 -m pip install wolk-connect

Installing from source

Clone this repository from the command line using:

git clone https://github.com/Wolkabout/WolkConnect-Python.git

Install dependencies by invoking python3 -m pip install -r requirements.txt

Install the package by running:

python3 setup.py install

Example Usage

Establishing connection with WolkAbout IoT platform

Create a device on WolkAbout IoT Platform by using the Simple example device type that is available on the platform. Note that device type can be created by importing `simple_example.json` file as new Device Type. This device type fits main.py and demonstrates the periodic sending of a temperature feed reading.

import wolk

# Setup the device credentials which you received
# when the device was created on the platform
device = wolk.Device(key="device_key", password="some_password")

# Pass your device and server information
# defaults to secure connection to Demo instance - comment out host, port and ca_cert
wolk_device = wolk.WolkConnect(
    device, host="insert_host", port=80, ca_cert="PATH/TO/YOUR/CA.CRT/FILE"
)

wolk_device.connect()

Adding feed values

wolk_device.add_feed_value(("T", 26.93))

# or multiple feed value readings
wolk_device.add_feed_value([("T", 27.11), ("H", 54.34), ("P", 1002.3)])

Optionally pass a timestamp as round(time.time()) * 1000. This is useful for maintaining data history when readings are not published immediately after adding them to storage. If timestamp is not provided, the library will assign a timestamp before placing the reading into storage.

Adding feed values with timestamp

# Add a signel feed reading to the message queue with the timestamp
wolk_device.add_feed_value(("T", 12.34), 1658315834000)

# Add a multi feed reading to the message queue with the timestamp
wolk_device.add_feed_value([("T", 12.34), ("H", 56.78), ("P", 1022.00)], 1658315834000)

Readings persistence and limit

Readings with method add_feed_value are added into local persistence. When adding messages be mindful of the message size that will be published. The default MQTT message size is 260MB, and since readings are of different sizes (based on the users use-case), check that the limit of readings in persistence will be under the MQTT limit for your broker. The default readings limit is set to 500000. You can change it with set_custom_readings_persistence_limit, if your readings are bigger, you can decrease the size, or if you have smaller readings, you can increase the size.

Data publish strategy

Stored feed values are pushed to WolkAbout IoT platform on demand by calling:

wolk_device.publish()

Adding feed values 'separated'

When adding feed values, the values themselves are persisted, which means when publishing all values will be placed in a single message and published as a single message.

If you would like to ensure different behavior, where you can add feed values that will be sent as a separate message from any other feed values, use the alternative method:

# Method arguments are exactly the same as for the `add_feed_value`
wolk_device.add_feed_value_separated([("T", 12.34), ("H", 56.78), ("P", 1022.00)], 1658315834000)

Disconnecting from the platform

wolk_device.disconnect()

Additional functionality

WolkConnect-Python library has integrated additional features which can perform full WolkAbout IoT platform potential. Explore the examples for more information.

Release files for wolk-connect 5.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wolk-connect 5.1.0
File Size Uploaded
wolk-connect-5.1.0.tar.gz 54.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wolk-connect 5.1.0
File Interpreter ABI Platform
wolk_connect-5.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 133.2 kB

Release files / wolk-connect-5.1.0.tar.gz

Download URL wolk-connect-5.1.0.tar.gz
Size 54.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6f58af36fbcdfe1365ead55dc1c5d1811be0526087651083d2b1b1fcbe0c35a5
BLAKE2b-256 checksum
How to use checksums
0c3ae171a9385cb75e98a67863b9112a46b9f812db7876c23ef1dc0b355b757b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release files / wolk_connect-5.1.0-py3-none-any.whl

Download URL wolk_connect-5.1.0-py3-none-any.whl
Size 78.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
edaca6934dd6b4c6033ece1ce51d74250729608f4c763329fab0fd6962822c16
BLAKE2b-256 checksum
How to use checksums
1c5fd7f952b3e6891725fb381c7c515fcf5cd76836fcfe5329c74eb509f7d261
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release history Release notifications | RSS feed

This release

5.1.0 This release

2 release files

5.0.1

2 release files

4.1.3

2 release files

4.1.2

2 release files

4.1.1

2 release files

4.1.0

2 release files

4.0.1

2 release files

4.0.0

3 release files

3.3.3

2 release files

3.3.2

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.1

2 release files

3.1.3

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.6

2 release files

3.0.5

2 release files

3.0.4

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page