sinricpro / esp8266-esp32-sdk

Library for https://sinric.pro - simple way to connect your device to Alexa, Google Home, SmartThings and cloud
https://sinric.pro
228 stars 122 forks source link

How to get Google Home to speak a text response from esp32 #216

Closed esp32noob closed 2 years ago

esp32noob commented 2 years ago

My goal: To ask GH "What is my weather", GH send web request to sinricpro, which sends web request to esp32, which responds with text to be read out by GH.

In issue #166 "sinricpro with ESPAsyncWebServer" there is a "webinterface" web reponse function that I'm sure I can manipulate to understand an incoming command and respond with a string of text. My question is: how do I define a device that accepts a command from GH, makes a web request to esp32 then returns to GH the text coming back from the esp32? I've looked at the examples and device types, and have sucessfully tried several, but they are all on/off or value based. I am new to sinricpro so please forgive my ignorance but I would appreciate any pointers as to where to look for this information.

sivar2311 commented 2 years ago

Unfortunately, there is a misunderstanding. This is not the way SmartHome control works. The voice commands are not transmitted from the servers to the SinricPro server but are converted to device-specific commands beforehand. So there is no possibility to receive the spoken sentences on the ESP, simply because this data never reaches us.

sivar2311 commented 2 years ago

Addendum:

166 only shows how to run an AsyncWebServer alongside the SinricProSDK on the ESP to host a WebServer on the ESP

esp32noob commented 2 years ago

Thankyou for your response. At the esp32 end I only need something to tell me to respond, so preferably it isn't voice, preferably a web request. The bit I'm missing is how do I get a web request from sinricpro, and how does sinricpro send the esp32 text response back to GH.

I wasn't clear in my request, I'll try again: I speak to GH and request the home weather. GH knows about a sinricpro device and sends something to sinricpro server. Sinricpro server somehow sends a websocket request to esp32. ESP32 responds with a text message that I create dynamically. Sinricpro server sends the text to GH which speaks the text.

I'm not sure if any of this is possible but I assume the bit in the middle is the device definition, i.e. a text response device. Does anything like this exist? Cheers Chris

sivar2311 commented 2 years ago

No, unfortunately, this is not possible, because the process is completely different from what you imagine.

In Google Home you have devices, for example a switch. You say "Turn on the switch". Google Home performs a voice recognition, finds the switch in your devices that is linked via SinricPro. Google Home sends a >>SmartHome command<< (not the recognized voice text) to the SinricPro server. SinricPro sends the command to the ESP and then it goes all the way back again. In SmartHome, a fixed protocol is used for this, which varies depending on the device type (a switch, for example, only knows the smart home commands ON and OFF).

esp32noob commented 2 years ago

Thankyou for your help. Sinricpro is a great product which I intend to use for several projects. I'll have to go back to the drawing board for my web request requirement. Thanks Chris