Skip to main content

IoT Device Communication Library

Project description

Palazzetti SDK - Local HUB

Library to interact with Palazzetti product via LOCAL HTTP HUB

Requires Python 3.6 and uses palazzetti-sdk-asset-parser to detect product capabilities.

import asyncio

from palazzetti_sdk_local_api import Hub

def main():
    loop = asyncio.get_event_loop()
    use_ip = "192.168.20.94"
    hub = Hub(use_ip)

    print("----- BEFORE UPDATE -----")
    print(f"ID Hub: {hub.hub_id}")
    print(f"Online: {hub.hub_online}")
    print(f"BioCC: {hub.hub_isbiocc}")
    print(f"Product Online: {hub.product_online}")
    print("Attributes:")
    print(hub.get_attributes())

    # now update the hub without discovery only via UDP (deep=False)
    print (f"Please wait, checking Hub at {use_ip}...")
    loop.run_until_complete(hub.async_update(discovery=False, deep=False))

    print("----- POST UPDATE -----")
    if hub.hub_online:
        print(f"Online: {hub.hub_online}")
        print(f"Label: {hub.label}")
        print(f"ID Hub: {hub.hub_id}")
        print(f"BioCC: {hub.hub_isbiocc}")
        print("Attributes:")
        print(hub.get_attributes())
        if hub.product_online:
            print(f"Product Online: {hub.product_online}")

            # now update the hub with discovery and HTTP failover if UDP fails (deep=True)
            print (f"Please wait, discovering product details for Hub {hub.hub_id}...")
            loop.run_until_complete(hub.async_update(discovery=True, deep=True))

            if hub.product and hub.product.online:
                print(f"ID Product: {hub.product.product_id}")
                print("Product Capabilities:")
                print(hub.product.get_data_config_json())
                print("Product Attributes:")
                print(hub.product.get_prod_data_json())
                return

            # this should neve happen...
            print ("Product should be online but has not been initiated")
            return

        print ("Hub is online but no Product found")
        return

    print ("Hub offline")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

palazzetti_sdk_local_api-1.0.14.tar.gz (9.6 kB view details)

Uploaded Source

File details

Details for the file palazzetti_sdk_local_api-1.0.14.tar.gz.

File metadata

  • Download URL: palazzetti_sdk_local_api-1.0.14.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for palazzetti_sdk_local_api-1.0.14.tar.gz
Algorithm Hash digest
SHA256 ffc2964a28675924c1f30ded283f5229c80e2c14ad287afb5451a389c433caa8
MD5 99fe3edd70f79dd9b1d39afe25515ceb
BLAKE2b-256 f243c026edd1d2c1dc123bb318238d586ffd4f4b957c59d9e3c1531b3eb57d56

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page