You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/iot-hub/iot-hub-python-twin-getstarted.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ In this section, you create a Python console app that adds location metadata to
65
65
4. Add the following code. Replace `[IoTHub Connection String]` with the IoT hub connection string you copied in [Get the IoT hub connection string](#get-the-iot-hub-connection-string). Replace `[Device Id]` with the device ID you registered in [Register a new device in the IoT hub](#register-a-new-device-in-the-iot-hub).
print("Devices in Redmond: {}".format(', '.join([twin.device_id for twin in query_result.items])))
95
+
print("Devices in Redmond43 plant: {}".format(', '.join([twin.device_id for twin in query_result.items])))
96
96
97
97
print()
98
98
99
99
query_spec = QuerySpecification(query="SELECT * FROM devices WHERE tags.location.plant = 'Redmond43' AND properties.reported.connectivity = 'cellular'")
print("Devices in Redmond using cellular network: {}".format(', '.join([twin.device_id for twin in query_result.items])))
101
+
print("Devices in Redmond43 plant using cellular network: {}".format(', '.join([twin.device_id for twin in query_result.items])))
102
102
103
103
exceptExceptionas ex:
104
104
print("Unexpected error {0}".format(ex))
105
105
return
106
106
exceptKeyboardInterrupt:
107
-
print("IoTHub sample stopped")
107
+
print("IoT Hub Device Twin service sample stopped")
108
108
```
109
109
110
110
The **IoTHubRegistryManager**object exposes all the methods required to interact with device twins from the service. The code first initializes the **IoTHubRegistryManager**object, then updates the device twin for**DEVICE_ID**, andfinally runs two queries. The first selects only the device twins of devices located in the **Redmond43** plant, and the second refines the query to select only the devices that are also connected through a cellular network.
@@ -113,7 +113,7 @@ In this section, you create a Python console app that adds location metadata to
113
113
114
114
```python
115
115
if__name__=='__main__':
116
-
print("Starting the IoT Hub Device Twins Python service sample...")
116
+
print("Starting the Python IoT Hub Device Twin service sample...")
117
117
print()
118
118
119
119
iothub_service_sample_run()
@@ -187,7 +187,7 @@ In this section, you create a Python console app that connects to your hub as yo
The **Client**object exposes all the methods you require to interact with device twins from the device. The previous code, after it initializes the **Client**object, retrieves the device twin for your device and updates its reported propertywith the connectivity information.
@@ -196,7 +196,7 @@ In this section, you create a Python console app that connects to your hub as yo
0 commit comments