зеркало из
1
0
Форкнуть 0
azure-iot-sdk-python/samples/pnp
Carter Tinney 047035b1bd
[V3] chore: Dropped support for Python 3.6 and added support for 3.11 (#1084)
* Removed support for 3.6
* Added official support for 3.11
* Removed tests related to 3.6
* Added (some) tests for 3.11
* Enabled automatic use of pytest-asyncio
* Removed backport utilities intended for 3.6
* Updated samples
* Updated documentation
* Improved reliability of E2E tests
2022-12-04 03:10:24 -08:00
..
README.md chore: Restructure repository for single project (#1030) 2022-08-04 12:58:57 -07:00
pnp_helper.py chore: Restructure repository for single project (#1030) 2022-08-04 12:58:57 -07:00
simple_thermostat.py [V3] chore: Dropped support for Python 3.6 and added support for 3.11 (#1084) 2022-12-04 03:10:24 -08:00
temp_controller_with_thermostats.py [V3] chore: Dropped support for Python 3.6 and added support for 3.11 (#1084) 2022-12-04 03:10:24 -08:00

README.md

page_type description languages products urlFragment
sample A set of Python samples that show how a device that uses the IoT Plug and Play conventions interacts with either IoT Hub or IoT Central.
python
azure-iot-hub
azure-iot-central
azure-iot-pnp
azure-iot-pnp-device-samples-for-python

IoT Plug And Play device samples

Documentation

These samples demonstrate how a device that follows the IoT Plug and Play conventions interacts with IoT Hub or IoT Central, to:

  • Send telemetry.
  • Update read-only and read-write properties.
  • Respond to command invocation.

The samples demonstrate two scenarios:

  • An IoT Plug and Play device that implements the Thermostat model. This model has a single interface that defines telemetry, read-only and read-write properties, and commands.
  • An IoT Plug and Play device that implements the Temperature controller model. This model uses multiple components:
    • The top-level interface defines telemetry, read-only property and commands.
    • The model includes two Thermostat components, and a device information component.

Quickstarts and tutorials

To learn more about how to configure and run the Thermostat device sample with IoT Hub, see Quickstart: Connect a sample IoT Plug and Play device application running on Linux or Windows to IoT Hub.

To learn more about how to configure and run the Temperature Controller device sample with:

Configuring the samples

Both samples use environment variables to retrieve configuration.

  • If you are using a connection string to authenticate:

    • set IOTHUB_DEVICE_SECURITY_TYPE="connectionString"
    • set IOTHUB_DEVICE_CONNECTION_STRING="<connection string of your device>"
  • If you are using a DPS enrollment group to authenticate:

    • set IOTHUB_DEVICE_SECURITY_TYPE="DPS"
    • set IOTHUB_DEVICE_DPS_ID_SCOPE="<ID Scope of DPS instance>"
    • set IOTHUB_DEVICE_DPS_DEVICE_ID="<Device's ID>"
    • set IOTHUB_DEVICE_DPS_DEVICE_KEY="<Device's security key >"
    • set IOTHUB_DEVICE_DPS_ENDPOINT="<DPS endpoint>"

Caveats

  • Azure IoT Plug and Play is only supported for MQTT and MQTT over WebSockets for the Azure IoT Python Device SDK. Modifying these samples to use AMQP, AMQP over WebSockets, or HTTP protocols will not work.

  • When the thermostat receives a desired temperature, it has no actual affect on the current temperature.

  • The command getMaxMinReport allows the application to specify statistics of the temperature since a given date. To keep the sample simple, we ignore this field and instead return statistics from the some portion of the lifecycle of the executable.

  • The temperature controller implements a command named reboot which takes a request payload indicating the delay in seconds. The sample will ignore doing anything on this command.