ePrivacy and GPDR Cookie Consent by TermsFeed Generator OpenHAB and AI: Full Gemini Integration with AI2MQTT Script and MQTT Protocol - VIDEO | OpenHAB - SmartHome | DomoticsDuino - Computer engineer, Smart Home / OpenHAB, Flight Sim and others...
OpenHAB - SmartHome (332 posts)

20/12/2025

OpenHAB and AI: Full Gemini Integration with AI2MQTT Script and MQTT Protocol - VIDEO [Versione in italiano]

by Marco Lamanna

In this video, I introduce my AI2MQTT script, a key step in integrating Gemini AI into smart home systems like OpenHAB.

AI2MQTT is a Python script (available on my GitHub repository https://github.com/domoticsduino/ai2mqtt) that acts as a bridge between home automation systems and the Gemini APIs.

The script was designed to allow systems like OpenHAB, which may not have the technical capability to integrate directly with AI APIs, to leverage their power via the MQTT protocol, an efficient protocol widely used in home automation.

  1. Sending the Request: OpenHAB (or any external system) sends prompt requests to Gemini on a specific MQTT topic.
  2. Generic: The script remains generic because it doesn't have the prompt hardwired into it, but receives it via the MQTT payload.
  3. JSON Schema: The prompt request must include a JSON schema. This is crucial because the AI ​​must return a schematic response rather than merely textual, making the data easily interpretable and usable by OpenHAB.
  4. Receiving the Response: Once the response is received from the Gemini 2.5 flash model, the script publishes it to a dedicated MQTT response topic, which is personalized with an identifier ('track') to separate responses to different requests.

In the video, I demonstrate installing and running the script using Docker Compose on a Raspberry Pi, and a practical test requesting a weather forecast for New York City, demonstrating the correct functioning of the AI2MQTT bridge.

Enjoy your viewing

[Open on YOUTUBE]