Skip to main content

Azure iot hub api with azure cli backend

Project description

azure-iot-hub-api

Azure IoT hub api interface using azure cli

This package is alternative to azure-iot-hub which hasn't had any updates in several years and relays on the deprecated azure-uamqp-python.

This package can be used as a stopgap until the azure-iot-hub been updated to no longer depend on deprecated packages.

Currently these very basic functionalities of the IoTHubRegistryManager are supported:

  • create_device_with_sas
  • get_twin
  • get_twins
  • update_twin
  • get_device
  • get_devices
  • delete_device

The package are designed, so that, if it is used as alternative to existing azure-iot-hub in the project, it need to make only little changes to the codebase.

Usage

Install package :

pip install azure-iot-hub-api

Simply import and create IoTHubRegistryManager using connection string, then you can call api functions.

Sample code

from azure_iot_hub_api import IoTHubRegistryManager

AZURE_IOT_CONNECTION_STRING = "HostName=MyAzureIotHub.azure-devices.net;SharedAccessKeyName=xxx;SharedAccessKey=xxxxxxxxxxxxxx"
registry_manager = IoTHubRegistryManager(AZURE_IOT_CONNECTION_STRING)
my_device_id = 'E-11'
primary_key = 'primary-base64-key'
secondary_key = 'secondary-base64-key'

# Create a device
registry_manager.create_device_with_sas(
        device_id=my_device_id,
        primary_key=primary_key,
        secondary_key=secondary_key,
        status='enabled',
    )

# Get device twin
my_device_twin = registry_manager.get_twin(device_id=my_device_id)
my_device_twin.properties.desired['speed'] = 70

# Update device twin (It updates only desired object)
registry_manager.update_twin(device_id=my_device_id, twin=my_device_twin)

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

azure_iot_hub_api-0.2.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

azure_iot_hub_api-0.2.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file azure_iot_hub_api-0.2.1.tar.gz.

File metadata

  • Download URL: azure_iot_hub_api-0.2.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for azure_iot_hub_api-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a9f84c6bec945cede1692916181cef4b614837051b642f299ab857631f4098ef
MD5 d445c435dfd5c4df09c1b4df218b0cce
BLAKE2b-256 d3750326c977e0360f9b2d2596ed9169982c67ee0c65814c1571a7b3f346331b

See more details on using hashes here.

File details

Details for the file azure_iot_hub_api-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for azure_iot_hub_api-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cdb96670dd2ddce667040671f23b2c9469cc03aacee451b3af2dbdde41590319
MD5 2e01bde6b95f579a26154c15813813e7
BLAKE2b-256 a7861ab70e09dcd61a410c3aa91feec9cc5fb68de8893386cb5b5fb23d857064

See more details on using hashes here.

Supported by

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