Skip to content

Commit

Permalink
raw mqtt lastwill only when HA Discovery is disabled. Both doesnt work!
Browse files Browse the repository at this point in the history
  • Loading branch information
Blueforcer committed Jan 14, 2025
1 parent 0988887 commit f12513a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/MQTTManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ MQTTManager_ &MQTTManager_::getInstance()
return instance;
}


MQTTManager_ &MQTTManager = MQTTManager.getInstance();

void processMqttMessage(const String &strTopic, const String &payloadCopy)
Expand Down Expand Up @@ -429,8 +428,10 @@ void onMqttConnected()

MQTTManager.publish("stats/effects", DisplayManager.getEffectNames().c_str());
MQTTManager.publish("stats/transitions", DisplayManager.getTransitionNames().c_str());
MQTTManager.publish("stats/device", "online");

if (!HA_DISCOVERY)
{
MQTTManager.publish("stats/device", "online");
}
connected = true;
}

Expand Down Expand Up @@ -466,9 +467,12 @@ void connect()
mqtt.onMessage(onMqttMessage);
mqtt.onConnected(onMqttConnected);

static char topic[50];
snprintf(topic, sizeof(topic), "%s/stats/device", MQTT_PREFIX.c_str());
mqtt.setLastWill(topic, "offline", false);
if (!HA_DISCOVERY)
{
static char topic[50];
snprintf(topic, sizeof(topic), "%s/stats/device", MQTT_PREFIX.c_str());
mqtt.setLastWill(topic, "offline", false);
}

if (MQTT_USER == "" || MQTT_PASS == "")
{
Expand Down

0 comments on commit f12513a

Please sign in to comment.