wolk-connect


Namewolk-connect JSON
Version 5.1.0 PyPI version JSON
download
home_pagehttps://github.com/Wolkabout/WolkConnect-Python
SummaryPython 3 library for connecting to WolkAbout IoT Platform
upload_time2023-06-05 07:17:14
maintainer
docs_urlNone
authorWolkAbout
requires_python
licenseApache License 2.0
keywords iot wolkabout internet of things
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ```console

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

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


```

[![Tests and Coverage](https://github.com/Wolkabout/WolkConnect-Python/actions/workflows/tests-and-coverage.yml/badge.svg?branch=development)](https://github.com/Wolkabout/WolkConnect-Python/actions/workflows/tests-and-coverage.yml) [![PyPI version](https://badge.fury.io/py/wolk-connect.svg)](https://badge.fury.io/py/wolk-connect) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/wolk-connect) ![GitHub](https://img.shields.io/github/license/wolkabout/WolkConnect-Python) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) [![Documentation Status](https://readthedocs.org/projects/wolkconnect-python/badge/?version=latest)](https://wolkconnect-python.readthedocs.io/en/latest/?badge=latest)
----
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

```console
python3 -m pip install wolk-connect
```

### Installing from source

Clone this repository from the command line using:

```console
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:

```console
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](https://github.com/Wolkabout/WolkConnect-Python/blob/master/examples/simple/main.py) and
demonstrates the periodic sending of a temperature feed reading.

```python
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

```python
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

```python
# 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:

```python
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:

```python
# 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

```python
wolk_device.disconnect()
```

## Additional functionality

WolkConnect-Python library has integrated additional features which can perform full WolkAbout IoT platform potential.
Explore the [examples](https://github.com/Wolkabout/WolkConnect-Python/tree/master/examples/) for more information.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Wolkabout/WolkConnect-Python",
    "name": "wolk-connect",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "IoT,WolkAbout,Internet of Things",
    "author": "WolkAbout",
    "author_email": "info@wolkabout.com",
    "download_url": "https://files.pythonhosted.org/packages/0c/3a/e171a9385cb75e98a67863b9112a46b9f812db7876c23ef1dc0b355b757b/wolk-connect-5.1.0.tar.gz",
    "platform": null,
    "description": "```console\n\n\u2588\u2588\u2557    \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557     \u2588\u2588\u2557  \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557   \u2588\u2588\u2557\u2588\u2588\u2588\u2557   \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\n\u2588\u2588\u2551    \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551     \u2588\u2588\u2551 \u2588\u2588\u2554\u255d\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255d\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557  \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557  \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255d\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255d\u255a\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255d\n\u2588\u2588\u2551 \u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551   \u2588\u2588\u2551\u2588\u2588\u2551     \u2588\u2588\u2588\u2588\u2588\u2554\u255d \u2588\u2588\u2551     \u2588\u2588\u2551   \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2557  \u2588\u2588\u2551        \u2588\u2588\u2551\n\u2588\u2588\u2551\u2588\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551   \u2588\u2588\u2551\u2588\u2588\u2551     \u2588\u2588\u2554\u2550\u2588\u2588\u2557 \u2588\u2588\u2551     \u2588\u2588\u2551   \u2588\u2588\u2551\u2588\u2588\u2551\u255a\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551\u255a\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255d  \u2588\u2588\u2551        \u2588\u2588\u2551\n\u255a\u2588\u2588\u2588\u2554\u2588\u2588\u2588\u2554\u255d\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551  \u2588\u2588\u2557\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u255a\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u255a\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2557   \u2588\u2588\u2551\n \u255a\u2550\u2550\u255d\u255a\u2550\u2550\u255d  \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d\u255a\u2550\u255d  \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d  \u255a\u2550\u2550\u2550\u255d\u255a\u2550\u255d  \u255a\u2550\u2550\u2550\u255d\u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d   \u255a\u2550\u255d\n\n                                           \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557   \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557  \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557   \u2588\u2588\u2557\n                                           \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u255a\u2588\u2588\u2557 \u2588\u2588\u2554\u255d\u255a\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255d\u2588\u2588\u2551  \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557  \u2588\u2588\u2551\n                                     \u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d \u255a\u2588\u2588\u2588\u2588\u2554\u255d    \u2588\u2588\u2551   \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551   \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\n                                     \u255a\u2550\u2550\u2550\u2550\u255d\u2588\u2588\u2554\u2550\u2550\u2550\u255d   \u255a\u2588\u2588\u2554\u255d     \u2588\u2588\u2551   \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551   \u2588\u2588\u2551\u2588\u2588\u2551\u255a\u2588\u2588\u2557\u2588\u2588\u2551\n                                           \u2588\u2588\u2551        \u2588\u2588\u2551      \u2588\u2588\u2551   \u2588\u2588\u2551  \u2588\u2588\u2551\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u255a\u2588\u2588\u2588\u2588\u2551\n                                           \u255a\u2550\u255d        \u255a\u2550\u255d      \u255a\u2550\u255d   \u255a\u2550\u255d  \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d  \u255a\u2550\u2550\u2550\u255d\n\n\n```\n\n[![Tests and Coverage](https://github.com/Wolkabout/WolkConnect-Python/actions/workflows/tests-and-coverage.yml/badge.svg?branch=development)](https://github.com/Wolkabout/WolkConnect-Python/actions/workflows/tests-and-coverage.yml) [![PyPI version](https://badge.fury.io/py/wolk-connect.svg)](https://badge.fury.io/py/wolk-connect) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/wolk-connect) ![GitHub](https://img.shields.io/github/license/wolkabout/WolkConnect-Python) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) [![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) [![Documentation Status](https://readthedocs.org/projects/wolkconnect-python/badge/?version=latest)](https://wolkconnect-python.readthedocs.io/en/latest/?badge=latest)\n----\nWolkAbout Python Connector library for connecting devices to WolkAbout IoT platform instance.\n\n## Prerequisite\n\n* Python 3.7+\n\n## Installation\n\nThere are two ways to install this package\n\n### Installing with pip\n\n```console\npython3 -m pip install wolk-connect\n```\n\n### Installing from source\n\nClone this repository from the command line using:\n\n```console\ngit clone https://github.com/Wolkabout/WolkConnect-Python.git\n```\n\nInstall dependencies by invoking `python3 -m pip install -r requirements.txt`\n\nInstall the package by running:\n\n```console\npython3 setup.py install\n```\n\n## Example Usage\n\n### Establishing connection with WolkAbout IoT platform\n\nCreate a device on WolkAbout IoT Platform by using the *Simple example* device type that is available on the\nplatform. ``Note that device type can be created by importing `simple_example.json` file as new Device Type.``\nThis device type fits [main.py](https://github.com/Wolkabout/WolkConnect-Python/blob/master/examples/simple/main.py) and\ndemonstrates the periodic sending of a temperature feed reading.\n\n```python\nimport wolk\n\n# Setup the device credentials which you received\n# when the device was created on the platform\ndevice = wolk.Device(key=\"device_key\", password=\"some_password\")\n\n# Pass your device and server information\n# defaults to secure connection to Demo instance - comment out host, port and ca_cert\nwolk_device = wolk.WolkConnect(\n    device, host=\"insert_host\", port=80, ca_cert=\"PATH/TO/YOUR/CA.CRT/FILE\"\n)\n\nwolk_device.connect()\n```\n\n### Adding feed values\n\n```python\nwolk_device.add_feed_value((\"T\", 26.93))\n\n# or multiple feed value readings\nwolk_device.add_feed_value([(\"T\", 27.11), (\"H\", 54.34), (\"P\", 1002.3)])\n```\n\nOptionally pass a `timestamp` as `round(time.time()) * 1000`.\nThis is useful for maintaining data history when readings are not published immediately after adding them to storage.\nIf `timestamp` is not provided, the library will assign a timestamp before placing the reading into storage.\n\n#### Adding feed values with timestamp\n\n```python\n# Add a signel feed reading to the message queue with the timestamp\nwolk_device.add_feed_value((\"T\", 12.34), 1658315834000)\n\n# Add a multi feed reading to the message queue with the timestamp\nwolk_device.add_feed_value([(\"T\", 12.34), (\"H\", 56.78), (\"P\", 1022.00)], 1658315834000)\n```\n\n### Readings persistence and limit\n\nReadings with method `add_feed_value` are added into local persistence. When adding messages be mindful of the\nmessage size that will be published. The default MQTT message size is 260MB, and since readings are of different sizes\n(based on the users use-case), check that the limit of readings in persistence will be under the MQTT limit for your broker.\nThe default readings limit is set to 500000. You can change it with `set_custom_readings_persistence_limit`, if your readings\nare bigger, you can decrease the size, or if you have smaller readings, you can increase the size.\n\n### Data publish strategy\n\nStored feed values are pushed to WolkAbout IoT platform on demand by calling:\n\n```python\nwolk_device.publish()\n```\n\n### Adding feed values 'separated'\n\nWhen adding feed values, the values themselves are persisted, which means when publishing all values will be placed\nin a single message and published as a single message.\n\nIf you would like to ensure different behavior, where you can add feed values that will be sent as a separate message\nfrom any other feed values, use the alternative method:\n\n```python\n# Method arguments are exactly the same as for the `add_feed_value`\nwolk_device.add_feed_value_separated([(\"T\", 12.34), (\"H\", 56.78), (\"P\", 1022.00)], 1658315834000)\n```\n\n### Disconnecting from the platform\n\n```python\nwolk_device.disconnect()\n```\n\n## Additional functionality\n\nWolkConnect-Python library has integrated additional features which can perform full WolkAbout IoT platform potential.\nExplore the [examples](https://github.com/Wolkabout/WolkConnect-Python/tree/master/examples/) for more information.\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Python 3 library for connecting to WolkAbout IoT Platform",
    "version": "5.1.0",
    "project_urls": {
        "Homepage": "https://github.com/Wolkabout/WolkConnect-Python"
    },
    "split_keywords": [
        "iot",
        "wolkabout",
        "internet of things"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c5fd7f952b3e6891725fb381c7c515fcf5cd76836fcfe5329c74eb509f7d261",
                "md5": "d618f8cf73be23439408a54474bebe8a",
                "sha256": "edaca6934dd6b4c6033ece1ce51d74250729608f4c763329fab0fd6962822c16"
            },
            "downloads": -1,
            "filename": "wolk_connect-5.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d618f8cf73be23439408a54474bebe8a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 78528,
            "upload_time": "2023-06-05T07:17:30",
            "upload_time_iso_8601": "2023-06-05T07:17:30.181800Z",
            "url": "https://files.pythonhosted.org/packages/1c/5f/d7f952b3e6891725fb381c7c515fcf5cd76836fcfe5329c74eb509f7d261/wolk_connect-5.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0c3ae171a9385cb75e98a67863b9112a46b9f812db7876c23ef1dc0b355b757b",
                "md5": "b2b3472afa920e3160abd188033b687c",
                "sha256": "6f58af36fbcdfe1365ead55dc1c5d1811be0526087651083d2b1b1fcbe0c35a5"
            },
            "downloads": -1,
            "filename": "wolk-connect-5.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b2b3472afa920e3160abd188033b687c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 54673,
            "upload_time": "2023-06-05T07:17:14",
            "upload_time_iso_8601": "2023-06-05T07:17:14.470834Z",
            "url": "https://files.pythonhosted.org/packages/0c/3a/e171a9385cb75e98a67863b9112a46b9f812db7876c23ef1dc0b355b757b/wolk-connect-5.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-05 07:17:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Wolkabout",
    "github_project": "WolkConnect-Python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "wolk-connect"
}
        
Elapsed time: 0.11638s