OpenBK7231T_App icon indicating copy to clipboard operation
OpenBK7231T_App copied to clipboard

mqtt forces relay on when connecting to broker regardless of settings

Open nosmaster89 opened this issue 1 month ago • 2 comments

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

nosmaster89 avatar Dec 04 '25 14:12 nosmaster89

Hey, so this happens with retain enabled or disabled?

openshwprojects avatar Dec 04 '25 14:12 openshwprojects

i had flag 21 (retain power channels ) originally . but today i have turned this off currently i only have flag 2,27,34 set. this has been a issue going back probably 18 months on different firmwares i just never dug to the root cause. only today due to network upgrades i looked deeper

nosmaster89 avatar Dec 04 '25 14:12 nosmaster89