Go to file
Eduard Iten 6e669cfc4e feat: Implement Homeassistant MQTT Gateway
This commit transforms the previous "Blinky" sample into a functional
Homeassistant MQTT Gateway application.

Key features and changes include:

- **Application Logic:** The core application logic is updated to function as a gateway between Modbus and MQTT.
- **Network Configuration:**
    - Implemented persistent network settings using the Zephyr settings subsystem and NVS.
    - Added robust Wi-Fi connection management with auto-reconnect.
    - Centralized IP configuration to support both DHCP and static IP addresses.
- **Configuration:** Project and board configurations have been updated to enable necessary kernel features and network settings.
- **Documentation:** The README has been updated to reflect the new functionality and usage instructions.
- **Simulation:** The simulation script has been updated.
2025-07-20 08:30:33 +02:00
.vscode feat: add doxygen headers to all functions 2025-07-19 09:10:05 +02:00
boards feat: Implement Homeassistant MQTT Gateway 2025-07-20 08:30:33 +02:00
src feat: Implement Homeassistant MQTT Gateway 2025-07-20 08:30:33 +02:00
.gitignore Initial commit: Set up Zephyr MQTT project 2025-07-17 08:49:06 +02:00
CMakeLists.txt feat: add doxygen headers to all functions 2025-07-19 09:10:05 +02:00
Kconfig feat: add doxygen headers to all functions 2025-07-19 09:10:05 +02:00
README.rst feat: Implement Homeassistant MQTT Gateway 2025-07-20 08:30:33 +02:00
prj.conf feat: Implement Homeassistant MQTT Gateway 2025-07-20 08:30:33 +02:00
run_sim.sh feat: Implement Homeassistant MQTT Gateway 2025-07-20 08:30:33 +02:00

README.rst

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> </head>

Modbus MQTT Gateway

Overview

This Zephyr application serves as an MQTT gateway, primarily designed to bridge Modbus devices with a Home Assistant instance. It connects to a WiFi network, obtains an IP address, and communicates with an MQTT broker.

Features

  • WiFi Connectivity: Connects to a specified WiFi network using credentials provided via Kconfig.
  • Network Configuration: Supports both DHCP and static IP addressing for flexible network integration.
  • MQTT Integration: Configured to communicate with an MQTT broker, with specific options for Home Assistant discovery.
  • Configurability: All major parameters, including WiFi, network, and MQTT settings, are configurable through Kconfig.
  • Simulation Support: Includes a script and configuration for running in a simulated environment (native_sim).

Configuration

The application is configured using Kconfig. Key options can be found in the "Home Assistant MQTT Options" menu.

  • WiFi Settings: - CONFIG_WIFI_SSID: The SSID of the WiFi network. - CONFIG_WIFI_PASSWORD: The password for the WiFi network.
  • Network Settings: - CONFIG_NET_DHCP: Enable or disable DHCP. - CONFIG_NET_IP_ADDR: Static IP address. - CONFIG_NET_IP_MASK: Static IP netmask. - CONFIG_NET_IP_GATEWAY: Static IP gateway. - CONFIG_NET_DNS_SERVER: Static DNS server.
  • MQTT Broker Settings: - CONFIG_HA_MQTT_BROKER_HOSTNAME: Hostname or IP of the MQTT broker. - CONFIG_HA_MQTT_BROKER_PORT: Port of the MQTT broker. - CONFIG_HA_MQTT_USERNAME: Username for MQTT authentication. - CONFIG_HA_MQTT_PASSWORD: Password for MQTT authentication.
  • Home Assistant Device Info: - CONFIG_HA_MQTT_NAME: Device name. - CONFIG_HA_MQTT_MANUFACTURER: Manufacturer name. - CONFIG_HA_MQTT_MODEL: Model name.

Building and Running

Building for Hardware (e.g., ESP32-C6)

System Message: WARNING/2 (<stdin>, line 53)

Cannot analyze code. Pygments package not found.

.. code-block:: shell

   west build -b esp32c6_devkitc_hpcore

Running in Simulation

A simulation can be run using the provided script:

System Message: WARNING/2 (<stdin>, line 61)

Cannot analyze code. Pygments package not found.

.. code-block:: shell

   ./run_sim.sh

This will build and run the application for the native_sim target.

</html>