Python 3 library for connecting to WolkAbout IoT Platform
Project description
██╗ ██╗ ██████╗ ██╗ ██╗ ██╗ ██████╗ ██████╗ ███╗ ██╗███╗ ██╗███████╗ ██████╗████████╗
██║ ██║██╔═══██╗██║ ██║ ██╔╝██╔════╝██╔═══██╗████╗ ██║████╗ ██║██╔════╝██╔════╝╚══██╔══╝
██║ █╗ ██║██║ ██║██║ █████╔╝ ██║ ██║ ██║██╔██╗ ██║██╔██╗ ██║█████╗ ██║ ██║
██║███╗██║██║ ██║██║ ██╔═██╗ ██║ ██║ ██║██║╚██╗██║██║╚██╗██║██╔══╝ ██║ ██║
╚███╔███╔╝╚██████╔╝███████╗██║ ██╗╚██████╗╚██████╔╝██║ ╚████║██║ ╚████║███████╗╚██████╗ ██║
╚══╝╚══╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝
██████╗ ██╗ ██╗████████╗██╗ ██╗ ██████╗ ███╗ ██╗
██╔══██╗╚██╗ ██╔╝╚══██╔══╝██║ ██║██╔═══██╗████╗ ██║
█████╗██████╔╝ ╚████╔╝ ██║ ███████║██║ ██║██╔██╗ ██║
╚════╝██╔═══╝ ╚██╔╝ ██║ ██╔══██║██║ ██║██║╚██╗██║
██║ ██║ ██║ ██║ ██║╚██████╔╝██║ ╚████║
╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
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)
Data publish strategy
Stored feed values are pushed to WolkAbout IoT platform on demand by calling:
wolk_device.publish()
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for wolk_connect-5.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e45396ebaba77cd84d8e5771bc2d7c1156b236377944f391873ea1cf32f2c390 |
|
MD5 | 7be69eb5f571b7ecca8f1377634c6cff |
|
BLAKE2b-256 | 896ade48b3bd7a7213d6a8de60135e771869f92a3482cd0d922970d77149af88 |