MQTT Structural Guidelines for Multi-Button Remote Control Integration

Greetings, fellow automation enthusiasts! I’m reaching out to seek some guidance on structuring MQTT topics and payloads for a multi-button remote control integration with openHAB. Let me share my setup and the challenges I’ve encountered so far.

Setup Overview:

  • Hardware: Raspberry Pi 3 B+ with a 120GB mSATA SSD in a USB enclosure.
  • OS: Raspbian Stretch.
  • openHAB Version: 2.4.0 release build.
  • MQTT Client: MQTT.fx and MQTT Explorer for monitoring.

Project Goal:
I’ve been working on integrating my kitchen ceiling fans into my home automation system using wall-mounted 433MHz remotes. My aim is to replace the cumbersome infrared remote that came with the fans with a more seamless, button-based control system.

Current Approach:
I initially tried to follow an openHAB + ESP8266 + MQTT tutorial, but it was overly complex and not well-documented. After some trial and error, I decided to break down the problem into smaller parts and started experimenting with MQTT outside of openHAB. I set up a system where each button press triggers a specific MQTT topic with a corresponding payload.

For example:

  • Left button press: home/mcu/LivingRoomMCU/433mhz/KitchenFan1 [0]
  • Middle button press: home/mcu/LivingRoomMCU/433mhz/KitchenFan2 [0]
  • Holding the middle button: home/mcu/LivingRoomMCU/433mhz/KitchenFan2 [1]

This seemed like a solid approach at first glance. However, when I tried to integrate openHAB into the mix, I realized that managing separate channels and items for each button was becoming unwieldy. I explored using wildcards to simplify the setup, but this introduced new challenges, such as not knowing which topic triggered the channel.

Challenges Faced:

  1. Wildcard Limitations: While wildcards can reduce redundancy, they don’t provide information about the specific topic that caused the trigger. This makes debugging and fine-tuning more difficult.
  2. Payload Structure: I considered altering the payload structure to include more descriptive information, such as Button1_Pressed or Button2_Held, but this feels like a workaround rather than a scalable solution.
  3. Efficiency Concerns: Subscribing to every individual topic and filtering within a script feels inefficient, especially for a system that should be lightweight and responsive.

Questions for the Community:

  • What is the recommended way to structure MQTT topics and payloads for a remote with multiple buttons, each having multiple functions?
  • How do experienced users of the MQTT binding for openHAB 2.x design their systems to avoid these limitations?
  • Are there best practices or design patterns that I’m missing that could streamline this process?

Desired Outcome:
I’m looking for insights or best practices that could help me design a more efficient and scalable MQTT structure. Whether it’s a different approach to topic naming, payload formatting, or channel configuration, I’m eager to learn from those with more experience in this area.

Thank you in advance for your time and assistance! I look forward to hearing your thoughts and experiences.

Best regards,
[Your Name]