Search code examples
dialogflow-esactions-on-google

How do you write a Google Action that posts to an API on the local network


I'm just starting out writing Google Actions for some home automation projects. I can't seem to find information on how to write an action that will POST to an API on the local network. I don't want to go outside the firewall to automate devices and services located on the local LAN. I have provided an image of what I'm looking to do. Diagram 1


Solution

  • You can't do this. The Google Home device doesn't (generally) have access to the local network and aside from basic voice processing, your Actions run in the cloud rather than the local device itself.

    Most devices that appear to act locally all contact a cloud-based service to do what they want. This allows your Assistant to act on them, even when the Assistant device (such as your phone) isn't on the LAN.

    Your options are pretty narrow:

    • See if IFTTT supports what you're trying to do and either use an API with IFTTT or use IFTTT directly from the Home.
    • Setup a tunnel between an endpoint on the public Internet and your LAN.
    • Setup a cloud-based service your local device checks for state changes (there are a variety of approaches you can take here).
    • A variant on that last one (inspired by @Nick's comment) is to have a single local hub that listens for changes in some cloud service and dispatches those changes locally. (Again, a variety of approaches.)