IoT Hub - Power Apps Control External Device

Ying Min Teo 1 Reputation point


Is it possible to control external device (e.g.: a lock) by connecting Power Apps and IoT Hub?
I want to use Power Apps to control open/close a safety box lock. Possible to connect Power Apps and IoT Hub together?
Or is there any better solution for this?


Azure IoT Central
Azure IoT Central
An Azure hosted internet of things (IoT) application platform.
331 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,083 questions
{count} votes

2 answers

Sort by: Most helpful
  1. AshokPeddakotla-MSFT 25,451 Reputation points

    @Ying Min Teo Please check the Unlock the Future of Azure IoT through Power Platform to understand how to use IoT hub and Power Apps to control an IoT device.

    You need to write a code (Ex. Node for IoT Hub) in Azure IoT Hub, to send commands directly to your IoT device and then create a flow in Power Automate, and connect that flow to a Power App, which will be a complete dashboard that controls the IoT device from anywhere in the world.

    Hope this helps. Do let us know if you have any further queries.

    If the response is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

  2. SatishBoddu-MSFT 19,826 Reputation points

    Hello @Ying Min Teo ,

    Adding to the above response posted by AshokPeddakotla-MSFT.

    As suggested by Ashok in the above response, please try to use the Power Apps flow and make use of the Azure IoThub REST API to call the direct methods on the IoT Device.



    Cloud-to-device communications guidance

    IoT Hub provides three options for device apps to expose functionality to a back-end app:

    • Direct methods for communications that require immediate confirmation of the result. Direct methods are often used for interactive control of devices such as turning on a fan.
    • Twin's desired properties for long-running commands intended to put the device into a certain desired state. For example, set the telemetry send interval to 30 minutes.
    • Cloud-to-device messages for one-way notifications to the device app.

    IoT Hub gives you the ability to invoke direct methods on devices from the cloud. Direct methods represent a request-reply interaction with a device similar to an HTTP call in that they succeed or fail immediately (after a user-specified timeout). This approach is useful for scenarios where the course of immediate action is different depending on whether the device was able to respond.

    Direct methods are implemented on the device and may require zero or more inputs in the method payload to correctly instantiate.

    Invoke a direct method from a back-end app

    To invoke a direct method from a back-end app use the Invoke device method REST API or its equivalent in one of the IoT Hub service SDKs.

    Method invocation
    Direct method invocations on a device are HTTPS calls that are made up of the following items:

    The request URI specific to the device along with the API version:{deviceId}/methods?api-version=2021-04-12  

    The POST method

    Headers that contain the authorization, content type, and content encoding.

    A transparent JSON body in the following format:

        "connectTimeoutInSeconds": 200,  
        "methodName": "reboot",  
        "responseTimeoutInSeconds": 200,  
        "payload": {  
            "input1": "someInput",  
            "input2": "anotherInput"  


    If the response is helpful, please click "Accept Answer" and upvote it. So that we can close this thread.

    0 comments No comments