It seems like device.on_command_executed is never called, even though my device is clearly receiving the method from IoT Central when looking at the log:
1861.44: INFO - C2D: => $iothub/methods/res/200/?$rid=1 with data {"Value": ""} and name => speaker
def command_executed(command_name: str, payload) -> IoTResponse:
print("Payload:", payload)
if command_name == "speaker":
commandPlaySpeaker(payload)
print("Command", command_name, "executed with payload", str(payload))
# return a status code and message to indicate if the command was handled correctly
return IoTResponse(200, "OK")
device.on_command_executed = command_executed
It seems like device.on_command_executed is never called, even though my device is clearly receiving the method from IoT Central when looking at the log:
1861.44: INFO - C2D: => $iothub/methods/res/200/?$rid=1 with data {"Value": ""} and name => speaker
The code, taken from the docs (https://docs.circuitpython.org/projects/azureiot/en/latest/index.html#azure-iot-central):
A similiar problem seems to have been reported on Stackoverflow: https://stackoverflow.com/questions/71110928/unable-to-send-command-from-iot-central-to-pyportal
Using CircuitPython 6.3.0 with Library Bundle 6.x on a Adafruit PyPortal.