Categories
Coding

Ok google 101 in c# – part 3

What is a Smart Home Intent

It’s a single command of our voice system. In case of thermostats could be:

  • Rise temperature
  • What’s the temperature?
  • Turn off heating

The Google Assistant will listen to the voice command, translate it into an Intent, and send the intent in JSON format to our fullfillment server (ASP.NET Web API).

Google Smart Home has four type of intents:

  • SYNC: require the list of devices. It’s the first request done by Google to our fullfillment server. Right after the OAuth exchange. In our case will return the list of thermostats.
  • QUERY: ask for the current state of the system. It’s a read-only request to know thermostat’s state: temperature, setpoints, power.
  • EXECUTE: require a command to be executed. For example: rise temperature by 2 degrees.
  • DISCONNECT: Issued by Google when the user unlink it’s thermostat account from Google Assistant account.

Thermostats

The Google Smart Home ecosystem features a lot of Device Type:

Every device has its capabilities(traits in the Google jargon) The recommended trait for thermostats is:

There is no limit on the traits a device can support. For example our thermostat could support also Brightness trait.

TemperatureSetting

This trait defines the most used features of a typical thermostat: temperatures and modes. It’s composed by attibutes, states and commands. These are the ones supported by our thermostat:

Attributes:

  • availableThermostatModes:
    • off: turn off thermostat itself, disabling heating/cooling.
    • heat: set thermostat in heating mode (Winter mode)
    • cool: set thermostat in cooling mode (Summer mode)
    • on: turn on thermostat. Restore its last functioning mode.
    • auto: set thermostat in scheduled mode

States:

  • thermostatMode: current functioning mode
  • thermostatTemperatureSetpoint: single target temperature in °C
  • thermostatTemperatureAmbient: observed temperature in °C

Commands:

  • ThermostatTemperatureSetpoint
    • thermostatTemperatureSetpoint: single target temperature to set [float type]
  • ThermostatSetMode
    • thermostatMode: set a functioning mode (heat/cool/auto/on/off)
  • TemperatureRelative
    • thermostatTemperatureRelativeDegree: rise or lower temperature b a number of degrees (Turn down 5 degrees)

Fullfillment server

Now that we have clear which intents to support, we can start developing our fullfillment server. It basically is:

  • ASP.NET Core Web API server
  • A single REST API that accepts JSON input
  • AWS Lambda to host the Web API server
  • AWS API Gateway to expose the lambda on internet

The fullfillment server is where the biggest development effort is required, and it’s described in part 4.

End of part 3Part 4

Leave a Reply

Your email address will not be published. Required fields are marked *