问题
I want to control my raspberry pi with my Google Home at college, but everything I find involves a server and opening a port which I can not do on my schools network.
Is there another way I can do this?
回答1:
The Google Home has no way to directly control other devices on the same network or through other wireless protocols. Everything goes through an Internet-based service and expects to communicate with devices via a server-based proxy. How that server communicates with the device is up to the developer.
Depending on your needs and capabilities, you do have a few options.
One option, for example, is to use a tool like ngrok to create a tunnel between the device itself and a service run by ngrok on the public Internet. Calls to the public https address are sent to a service running locally on your device, and you can handle it accordingly.
Another is to have your device connect to a server and listen for command changes, and then execute those changes. If you don't want to run a server, you can even use something like Firebase - have your device listen for changes on the real-time database (which can use the HTTPS port to communicate as a client, so you don't open anything) and have something like a Firebase Cloud Function act as the webhook for your Action.
回答2:
Go through this blog post: http://nilhcem.com/android-things/google-assistant-smart-home
You will have to set up a OAuth server but as @Prisoner said you can use ngrok to tunnel the device to internet, BUT I would recommend using "localtunnel" as it provides a free static url and the set-up is also easy. NO Port Forwarding is required with this method.
More info on localtunnel setup:- How to generate fixed url with ngrok
Moreover you need to activate the OAuth server only once for account linking & than you can close it.
来源:https://stackoverflow.com/questions/53951977/connecting-a-raspberry-pi-to-a-google-home