NabuCasa / home-assistant-google-assistant-local-sdk

Google Assistant Local SDK implementation for Home Assistant
GNU General Public License v3.0
99 stars 12 forks source link

Local fulfillment is assuming only a single command in a request batch #10

Closed bbangert closed 2 years ago

bbangert commented 2 years ago

The local fulfillment is only responding to a single input. However, Google may group commands in a single request which are then getting ignored, this can cause Google to fall-back to the cloud to request the state of the devices to see if the command succeeded, however Home-Assistant also has a bug where it only processes a single input in a grouped batch. This will cause Google to report that there was an issue, even though everything may have in fact happened with local fulfillment.

The code should iterate over the inputs and include each response for every input to ensure Google is notified of the response for all of its commands.

Example portions where only a single input is used: https://github.com/NabuCasa/home-assistant-google-assistant-local-sdk/blob/18032040ae8346cc3365542e5ce213bf3b35ad32/app.ts#L80 https://github.com/NabuCasa/home-assistant-google-assistant-local-sdk/blob/18032040ae8346cc3365542e5ce213bf3b35ad32/app.ts#L156 https://github.com/NabuCasa/home-assistant-google-assistant-local-sdk/blob/18032040ae8346cc3365542e5ce213bf3b35ad32/app.ts#L176 https://github.com/NabuCasa/home-assistant-google-assistant-local-sdk/blob/18032040ae8346cc3365542e5ce213bf3b35ad32/app.ts#L215 https://github.com/NabuCasa/home-assistant-google-assistant-local-sdk/blob/18032040ae8346cc3365542e5ce213bf3b35ad32/app.ts#L226 https://github.com/NabuCasa/home-assistant-google-assistant-local-sdk/blob/18032040ae8346cc3365542e5ce213bf3b35ad32/app.ts#L242

Note that this will require a fairly substantial refactor as the assumption is through-out the command handling.

bbangert commented 2 years ago

Closing as this is safe behavior at the moment as Google also assumes a single intent per request: https://github.com/actions-on-google/actions-on-google-nodejs/blob/e069502f4d179a9ee88a5466ba7cbfe47287fe75/src/service/smarthome/smarthome.ts#L501