Skip to content

Mqtt -> qos and retain not set right #2656

@KrX3D

Description

@KrX3D

What happened?

hello,

im trying to creat an usermod which send out some mqtt parameters, but the qos and retain is not set right.

doing something like this:

char buffer[64];
sprintf_P(buffer, PSTR("%s/config/seg/%d/Red"), mqttDeviceTopic, CurrSeg);
mqtt->publish(buffer, 2, true, String(ColR).c_str());	

and i receive in Home Assistant -> QoS: 0 - Retain: false

i searched a bit and found in mqtt.cpp from line 124 this:

char s[10];
char subuf[38];

sprintf_P(s, PSTR("%u"), bri);
strlcpy(subuf, mqttDeviceTopic, 33);
strcat_P(subuf, PSTR("/g"));
mqtt->publish(subuf, 0, true, s);         // retain message

which should get a result like this: QoS: 0 - Retain: true but it also is received as QoS: 0 - Retain: false

image

To Reproduce Bug


		char buffer[64];
		sprintf_P(buffer, PSTR("%s/config/seg/%d/Red"), mqttDeviceTopic, CurrSeg);
		mqtt->publish(buffer, 2, true, String(ColR).c_str());	

on home assistant, mqtt broker receives: QoS: 0 - Retain: false

Expected Behavior

QoS: 2 - Retain: true

Install Method

Self-Compiled

What version of WLED?

WLED 0.13.1

Which microcontroller/board are you seeing the problem on?

ESP8266

Relevant log/trace output

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdependenciesPull requests that update a dependency filenot_plannedno change plannedstaleThis issue will be closed soon because of prolonged inactivity

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions