1

We have an already running MQTT setup for communication between smart home devices and remote server, for remotely controlling the devices. Now we want to integrate our devices with Google Home and Alexa. These two use HTTP for communication with third party device clouds.

I have implemented this for Google Home and after receiving the request to device cloud, the request is converted to MQTT. This MQTT request is then sent to smart home device. The device cloud waits for few seconds to receive reply from smart home device. If no reply is received within predefined time, it then sends failure HTTP response to Google Home else it sends the received reply.

Is there a better way to handle this? Since this is a commercial project I want to get this implemented in the correct way.

1

For a blackbox type system such as Google Home or Amazon Echo, this is the proper approach. If anything you could fine-tune timeouts to be based on the type of request being made. In other words if a certain request tends to take longer, you can simply wait longer for that type of request.

However, it's important to make the distinction between how a blackbox system should work and how it actually works. The timeout is meant to protect you against the type of problem where you receive no response at all. Perhaps that isn't how it should work, but you should prepare for all possibilities. Likewise should you prepare for the eventuality of receiving a response that cannot be properly parsed (pro tip here: log that response and create an error report to send to you in such cases).

If there are no unexpected results, then the behavior of your web app remains consistent. And in cases in which there are unexpected results, the behavior of your web app still remains consistent regardless. This is the basis for communication with a blackbox system.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.