Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions adafruit_azureiot/iot_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def device_twin_desired_updated(self, desired_property_name: str, desired_proper
:param int desired_version: The version of the desired property that was updated
"""

def device_twin_reported_updated(self, reported_property_name: str, reported_property_value, reported_version: int) -> None:
def device_twin_reported_updated(self, reported_property_name: str, reported_property_value, reported_version: int,) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this extra comma do anything?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jimbobbennett Hrm, I didn't add them. These may have been added by black'ing the file.

"""Called when the device twin reported values are updated
:param str reported_property_name: The name of the reported property that was updated
:param reported_property_value: The value of the reported property that was updated
Expand Down Expand Up @@ -143,11 +143,7 @@ def _try_create_mqtt_client(self, hostname: str) -> None:
self._mqtts.connect()

def _create_mqtt_client(self) -> None:
try:
self._try_create_mqtt_client(self._hostname)
except ValueError:
# Workaround for https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT/issues/25
self._try_create_mqtt_client("https://" + self._hostname)
self._try_create_mqtt_client(self._hostname)

# pylint: disable=C0103, W0613
def _on_connect(self, client, userdata, _, rc) -> None:
Expand Down
8 changes: 5 additions & 3 deletions adafruit_azureiot/iotcentral_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def device_twin_desired_updated(self, desired_property_name: str, desired_proper
# when a desired property changes, update the reported to match to keep them in sync
self.send_property(desired_property_name, desired_property_value)

def device_twin_reported_updated(self, reported_property_name: str, reported_property_value, reported_version: int) -> None:
def device_twin_reported_updated(self, reported_property_name: str, reported_property_value, reported_version: int,) -> None:
"""Called when the device twin reported values are updated
:param str reported_property_name: The name of the reported property that was updated
:param reported_property_value: The value of the reported property that was updated
Expand All @@ -86,7 +86,9 @@ def device_twin_reported_updated(self, reported_property_name: str, reported_pro
self.on_property_changed(reported_property_name, reported_property_value, reported_version)

# pylint: disable=R0913
def __init__(self, socket, iface, id_scope: str, device_id: str, key: str, token_expires: int = 21600, logger: logging = None):
def __init__(
self, socket, iface, id_scope: str, device_id: str, key: str, token_expires: int = 21600, logger: logging = None,
):
"""Create the Azure IoT Central device client
:param socket: The network socket
:param iface: The network interface
Expand Down Expand Up @@ -136,7 +138,7 @@ def connect(self) -> None:

token_expiry = int(time.time() + self._token_expires)
hostname = self._device_registration.register_device(token_expiry)
self._mqtt = IoTMQTT(self, self._socket, self._iface, hostname, self._device_id, self._key, self._token_expires, self._logger)
self._mqtt = IoTMQTT(self, self._socket, self._iface, hostname, self._device_id, self._key, self._token_expires, self._logger,)

self._mqtt.connect()
self._mqtt.subscribe_to_twins()
Expand Down
8 changes: 5 additions & 3 deletions adafruit_azureiot/iothub_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def device_twin_desired_updated(self, desired_property_name: str, desired_proper
# pylint: disable=E1102
self._on_device_twin_desired_updated(desired_property_name, desired_property_value, desired_version)

def device_twin_reported_updated(self, reported_property_name: str, reported_property_value, reported_version: int) -> None:
def device_twin_reported_updated(self, reported_property_name: str, reported_property_value, reported_version: int,) -> None:
"""Called when the device twin reported values are updated
:param str reported_property_name: The name of the reported property that was updated
:param reported_property_value: The value of the reported property that was updated
Expand All @@ -128,7 +128,9 @@ def device_twin_reported_updated(self, reported_property_name: str, reported_pro
# pylint: disable=E1102
self._on_device_twin_reported_updated(reported_property_name, reported_property_value, reported_version)

def __init__(self, socket, iface, device_connection_string: str, token_expires: int = 21600, logger: logging = None):
def __init__(
self, socket, iface, device_connection_string: str, token_expires: int = 21600, logger: logging = None,
):
"""Create the Azure IoT Central device client
:param socket: The network socket
:param iface: The network interface
Expand Down Expand Up @@ -267,7 +269,7 @@ def connect(self) -> None:
:raises RuntimeError: if the internet connection is not responding or is unable to connect
"""
self._mqtt = IoTMQTT(
self, self._socket, self._iface, self._hostname, self._device_id, self._shared_access_key, self._token_expires, self._logger
self, self._socket, self._iface, self._hostname, self._device_id, self._shared_access_key, self._token_expires, self._logger,
)
self._mqtt.connect()

Expand Down
7 changes: 6 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
autodoc_mock_imports = ["adafruit_logging", "adafruit_requests", "adafruit_hashlib", "adafruit_ntp"]
autodoc_mock_imports = [
"adafruit_logging",
"adafruit_requests",
"adafruit_hashlib",
"adafruit_ntp",
]


intersphinx_mapping = {
Expand Down
4 changes: 3 additions & 1 deletion examples/iotcentral_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@
# Properties can be updated either in code, or by adding a form to the view
# in the device template, and setting the value on the dashboard for the device
def property_changed(property_name, property_value, version):
print("Property", property_name, "updated to", str(property_value), "version", str(version))
print(
"Property", property_name, "updated to", str(property_value), "version", str(version),
)


# Subscribe to the property changed event
Expand Down
4 changes: 3 additions & 1 deletion examples/iothub_twin_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@
# or in the Azure portal by selecting the device in the IoT Hub blade, selecting
# Device Twin then adding or amending an entry in the 'desired' section
def device_twin_desired_updated(desired_property_name: str, desired_property_value, desired_version: int):
print("Property", desired_property_name, "updated to", str(desired_property_value), "version", desired_version)
print(
"Property", desired_property_name, "updated to", str(desired_property_value), "version", desired_version,
)


# Subscribe to the device twin desired property updated event
Expand Down