Help automating Hardware+ software combination


I want to know if we can automate something like: where we are registering a hardware device to the app.

workflow: I will open my app >> start registering the device to the app by following steps on the app >> locate the nearby device through wifi >> select my hardware device >> connect my device to wifi >> (tricky part ) now my app tells me to push the button on my hardware device to register it to app ( which is something outside the app ) >> when the app triggers that button click thing on the backend then it displays a successful message on the app . ( this is the process that I need to automate) some of the workflow is missing in this video. The Button pushing thing is not shown here.

Can someone help me how to do that? what tools I need to install ?