From cc623aeab01ced0fd2d1a3394861d06eeab41ed6 Mon Sep 17 00:00:00 2001 From: Softwarecrash Date: Wed, 8 Nov 2023 16:36:11 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20HA=20Discovery=20retain=20?= =?UTF-8?q?flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformio.ini | 2 +- src/main.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index 0652acf..cdec814 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,7 +12,7 @@ platform = espressif8266 framework = arduino monitor_speed = 115200 -custom_prog_version = 1.1.2 +custom_prog_version = 1.1.3 build_flags = -DVERSION=${this.custom_prog_version} -DPIO_SRC_NAM="Solar2MQTT" diff --git a/src/main.cpp b/src/main.cpp index 7b19c56..3400f78 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -705,7 +705,7 @@ bool sendHaDiscovery() sprintf(topBuff, "homeassistant/sensor/%s/%s/config", settings.data.deviceName, haStaticDescriptor[i][0]); // build the topic mqttContentLength = sprintf(configBuff, "{\"state_topic\": \"%s/DeviceData/%s\",\"unique_id\": \"sensor.%s_%s\",\"name\": \"%s\",\"icon\": \"%s\",\"unit_of_measurement\": \"%s\",\"device_class\":\"%s\",\"device\":{\"identifiers\":[\"%s\"], \"configuration_url\":\"http://%s\",\"name\":\"%s\", \"model\":\"%s\",\"manufacturer\":\"SoftWareCrash\",\"sw_version\":\"Solar2MQTT %s\"}}", settings.data.mqttTopic, haStaticDescriptor[i][0], settings.data.deviceName, haStaticDescriptor[i][0], haStaticDescriptor[i][0], haStaticDescriptor[i][1], haStaticDescriptor[i][2], haStaticDescriptor[i][3], staticData["Serial_number"].as().c_str(), (const char *)(WiFi.localIP().toString()).c_str(), settings.data.deviceName, staticData["Device_Model"].as().c_str(), SOFTWARE_VERSION); - mqttclient.beginPublish(topBuff, mqttContentLength, false); + mqttclient.beginPublish(topBuff, mqttContentLength, true); for (size_t i = 0; i < mqttContentLength; i++) { mqttclient.write(configBuff[i]); @@ -721,7 +721,7 @@ bool sendHaDiscovery() sprintf(topBuff, "homeassistant/sensor/%s/%s/config", settings.data.deviceName, haLiveDescriptor[i][0]); // build the topic mqttContentLength = sprintf(configBuff, "{\"state_topic\": \"%s/LiveData/%s\",\"unique_id\": \"sensor.%s_%s\",\"name\": \"%s\",\"icon\": \"%s\",\"unit_of_measurement\": \"%s\",\"device_class\":\"%s\",\"device\":{\"identifiers\":[\"%s\"], \"configuration_url\":\"http://%s\",\"name\":\"%s\", \"model\":\"%s\",\"manufacturer\":\"SoftWareCrash\",\"sw_version\":\"Solar2MQTT %s\"}}", settings.data.mqttTopic, haLiveDescriptor[i][0], settings.data.deviceName, haLiveDescriptor[i][0], haLiveDescriptor[i][0], haLiveDescriptor[i][1], haLiveDescriptor[i][2], haLiveDescriptor[i][3], staticData["Serial_number"].as().c_str(), (const char *)(WiFi.localIP().toString()).c_str(), settings.data.deviceName, staticData["Device_Model"].as().c_str(), SOFTWARE_VERSION); - mqttclient.beginPublish(topBuff, mqttContentLength, false); + mqttclient.beginPublish(topBuff, mqttContentLength, true); for (size_t i = 0; i < mqttContentLength; i++) { mqttclient.write(configBuff[i]);