Pradip Shenolkar
Pradip Shenolkar

Reputation: 817

Smart home device integration with Google home and Alexa

I am trying to integrate smart home devices with Google home and Alexa but I am facing following issue.

  1. Communication between Google Home/Alexa and our device cloud server is HTTP.
  2. Communication between smart home device and our device cloud server is MQTT.

How do I keep track of synchronous request-response? Is there a better way to implement this system?

Upvotes: 0

Views: 392

Answers (2)

Peter K.
Peter K.

Reputation: 1

The project gBridge (https://github.com/kservices/gBridge; https://about.gbridge.io) basically implements plain Google Assistant/ Alexa to MQTT bridging.

Regarding your questions, there are two points that help to implement these solutions:

  1. Think in terms of devices or endpoints, rather than requests. When you just want to "translate" HTTP to MQTT, you are inducing a lot of issues like you've figured out. You probably want to implement a logic that allows MQTT topics to control/ query your actual deviecs - not ones that respond to HTTP requests. This makes thing a whole lot simpler.
  2. Caching is essential. Allow your bridge to have a local copy of your device's states. When having the properly implemented cache, you won't need for any response. Just use the cached data.

Upvotes: 0

hardillb
hardillb

Reputation: 59801

Perfectly possibly to do with HTTP to MQTT and back again.

I've done it for both Alexa & Google Home for my Node-RED nodes.

You just need to keep track of on going requests and include a unique id in the request/response MQTT messages while also running a timer to handle no response from the device.

Upvotes: 1

Related Questions