Skip to content

mqtt forces relay on when connecting to broker regardless of settings #1883

@nosmaster89

Description

@nosmaster89

Describe the bug
when mqtt is set up . if the device reconnects to the broker it will force the devices relay into the on state turning the lights on .regardless of flags or startup configs . if mqtt is enabled the device will not reconnect and stay powered down
Firmware:

  • Version 1.18.223
  • Device? smart switch
  • Chip/model: ln-02?
  • Device config?
  • channel 1 (relay) is set to remeber last state (-1) this works fine when mqtt is not connected.
    • flags: 17314086916
    "vendor": "Tuya",
    "bDetailed": "0",
    "name": "Full Device Name Here",
    "model": "enter short model name here",
    "chip": "LN882H",
    "board": "TODO",
    "flags": "134217732",
    "keywords": [
      "TODO",
      "TODO",
      "TODO"
    ],
    "pins": {
      "1": "Rel;1",
      "19": "LED;1"
    },
    "command": "",
    "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
    "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"```
    
    

To Reproduce
Steps to reproduce the behavior:

  1. disconnect from mqtt broker / reboot / reconnect to network .
  2. device on reconnect will always return the relay to the on position

logs:

Info:MQTT:mqtt_connection_cb: Successfully connected
Info:MQTT:mqtt_subscribed to frontroomceiling/+/set
Info:MQTT:mqtt_subscribed to bekens/+/set
Info:MQTT:mqtt_subscribed to cmnd/frontroomceiling/+
Info:MQTT:mqtt_subscribed to cmnd/bekens/+
Info:MQTT:mqtt_subscribed to frontroomceiling/+/get
Info:MQTT:mqtt_subscribed to homeassistant/+
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic frontroomceiling/1/set
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic frontroomceiling/1/get
Debug:MQTT:channelSet topic 536969692 with arg 1
Info:MQTT:MQTT client in mqtt_incoming_data_cb data is 1 for ch 1
Info:MQTT:Channel has changed! Publishing 1 to channel 1 
Info:MQTT:Publishing val 1 to frontroomceiling/1/get retain=0
Debug:MQTT:channelSet topic 536969692 with arg 1
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic frontroomceiling/1/get
Debug:MQTT:channelSet topic 536969692 with arg 1
Info:MQTT:Publishing val front_room_light to frontroomceiling/host retain=0
Info:MQTT:Publishing val OpenLN882H 1.18.223 Dec  3 2025 15:05:29 to frontroomceiling/build retain=0
Info:MQTT:Publishing val 00:50:c2:d6:d8:ea to frontroomceiling/mac retain=0
Info:MQTT:Publishing val 60.04 to frontroomceiling/temp retain=0
Info:MQTT:Publishing val Home1 to frontroomceiling/ssid retain=0
Info:MQTT:Publishing val 0 to frontroomceiling/sockets retain=0
Info:MQTT:Publishing val -66 to frontroomceiling/rssi retain=0
Info:MQTT:Publishing val 1847 to frontroomceiling/uptime retain=0
Info:MQTT:Publishing val 65120 to frontroomceiling/freeheap retain=0
Info:MQTT:Publishing val 172.16.50.206 to frontroomceiling/ip retain=0
Info:MQTT:Channel has changed! Publishing 1 to channel 1 
Info:MQTT:Publishing val 1 to frontroomceiling/1/get retain=0
Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic frontroomceiling/1/get
Debug:MQTT:channelSet topic 536969692 with arg 1

i consulted chatgpt as im not to familiar with this code base. and it implied the problem was the subscription to the get topic. i have been fighting this for a long time. but only today did i get to the cause being mqtt. i really dont want to have to dig about in the roof to change this switch out for something else.
in forums i see people complaining about retain last state and mqtt is brought up alot to "turn off " but no explination is given to why mqtt is a problem or how to fix it
TIA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions