Issues with MQTT config and adding Custom-Built ESP Light

Hello everyone,

I’m encountering some challenges trying to control my custom-built ESP RGB light through MQTT in Home Assistant.

Setup:

  • Light: Custom-built ESP-based RGB light
  • MQTT-Broker: Mosquitto
  • Zigbee2MQTT (fyi, maybe not relevant here)

Description:

  • Manual Control:
    I can manually control the light using the following command:

    mosquitto_pub -h $IP -u $USER -P $PASSWORD -t "esp/tvbacklight/led/col" -m "white"
    
  • MQTT-Addon Error:
    When I try to configure the MQTT-Addon through the WebUI, I get the following error:

    "Already configured. Only one configuration allowed."
    
  • Configuration Issue:
    I’ve placed my MQTT configuration in config/configuration.yaml, but it doesn’t seem to be the right file for device configuration (e.g. no effect). I recently transitioned from OpenHAB to Home Assistant, so I’m still getting accustomed to the file structure. Can someone point me to the correct file for device configurations? For now, the specific topic and payload details aren’t crucial as I’m monitoring the MQTT messages using mosquitto_sub with the topic esp/#.

    My current configuration looks like this:

    mqtt:
      - switch:
          command_topic: "esp/tvbacklight/led/col"
    
  • Light Control Script:
    I have created a script that controls the light, and it works as expected:

    alias: TV backlight on
    description: ""
    trigger:
      - platform: state
        entity_id:
          - input_boolean.mqtt_test_switch
        from: "off"
        to: "on"
    condition: []
    action:
      - service: mqtt.publish
        data:
          qos: 0
          retain: false
          payload: white
          topic: esp/tvbacklight/led/col
    mode: single
    
  • Additional Information:
    Additionally, I’d like to mention that zigbee2mqtt works flawlessly for me. It can automatically detect and add new devices without any issues.

Has anyone experienced similar challenges or can provide guidance on how to correct the MQTT configuration in Home Assistant? Any help would be greatly appreciated!

Thank you in advance!

Best regards,
Archer

I’ve observed that zigbee2mqtt can automatically add and modify MQTT devices. My attempt to send such an auto-config message unfortunately didn’t succeed. This would be a viable alternative for me. Despite my efforts, I haven’t been successful yet. If someone could provide a sample message, I’d be more than happy to write a Python script to auto-configure my devices. This solution would be both feasible and elegant.

Hoping for some guidance here.

Best,