Google Home Foyer API Stubs

1.2.2 · active · verified Thu Apr 16

ghome-foyer-api provides generated protobuf stubs for interacting with the Google Home Foyer API. This library simplifies client-side development for devices that expose this gRPC interface. It currently supports protobuf v5 and v6, with releases often driven by updates to underlying gRPC and protobuf dependencies.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import the generated stubs and create a gRPC client stub for the Foyer service. This quickstart assumes a gRPC server implementing the Google Home Foyer API is running and accessible at the specified `SERVER_ADDRESS`.

import grpc
from ghome_foyer_api import foyer_v1_pb2_grpc, foyer_v1_pb2
import os

# This library provides generated protobuf/gRPC stubs for the Google Home Foyer API.
# It requires a running gRPC server that implements this API (e.g., a Google Home device
# exposing the Foyer API on the local network) to be functional.

# Replace with the actual address of your Google Home Foyer API server.
# For local testing or development, 'localhost:50051' is a common placeholder.
SERVER_ADDRESS = os.environ.get('GHOME_FOYER_API_SERVER_ADDRESS', 'localhost:50051')

try:
    # Establish an insecure gRPC channel to the server.
    # For production environments, consider secure channels (e.g., `grpc.ssl_channel`).
    with grpc.insecure_channel(SERVER_ADDRESS) as channel:
        # Create a stub for the Foyer service.
        # This object exposes the RPC methods defined in the Foyer API.
        stub = foyer_v1_pb2_grpc.FoyerStub(channel)

        print(f"Successfully created FoyerStub for server at {SERVER_ADDRESS}")
        print("To interact, call specific RPC methods defined in the Foyer API using 'stub.'")
        # Example (illustrative, actual method names and parameters vary per API):
        # request = foyer_v1_pb2.GetDeviceInfoRequest(device_id='some_id')
        # response = stub.GetDeviceInfo(request)
        # print(f"Device Info: {response}")

except grpc.RpcError as e:
    print(f"Error connecting or calling gRPC: {e.code().name} - {e.details()}")
    print("Ensure the gRPC server is running and accessible at the specified address.")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →