Skip to content

Commit

Permalink
correct HA discovery retain flag
Browse files Browse the repository at this point in the history
  • Loading branch information
softwarecrash committed Nov 8, 2023
1 parent 630de19 commit b3afabb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
platform = espressif8266
framework = arduino
monitor_speed = 115200
custom_prog_version = 2.10.0
custom_prog_version = 2.10.0A

build_flags =
-DVERSION=${this.custom_prog_version}
Expand Down
10 changes: 5 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ bool sendHaDiscovery()
sprintf(topBuff, "homeassistant/sensor/%s/%s/config", _settings.data.mqttTopic, haPackDescriptor[i][0]); // build the topic
mqttContentLength = sprintf(configBuff, "{\"state_topic\": \"%s/%s\",\"unique_id\": \"sensor.%s_%s\",\"name\": \"%s\",\"icon\": \"%s\",\"unit_of_measurement\": \"%s\",\"device_class\":\"%s\",\"device\":{\"identifiers\":[\"%06X\"], \"configuration_url\":\"http://%s\",\"name\":\"%s\", \"model\":\"Daly2MQTT\",\"manufacturer\":\"SoftWareCrash\",\"sw_version\":\"Solar2MQTT %s\"}}",
_settings.data.mqttTopic, haPackDescriptor[i][0], _settings.data.deviceName, haPackDescriptor[i][0], haPackDescriptor[i][0], haPackDescriptor[i][1], haPackDescriptor[i][2], haPackDescriptor[i][3], ESP.getChipId(), (const char *)(WiFi.localIP().toString()).c_str(), _settings.data.deviceName, SOFTWARE_VERSION);
mqttclient.beginPublish(topBuff, mqttContentLength, false);
mqttclient.beginPublish(topBuff, mqttContentLength, true);
for (size_t i = 0; i < mqttContentLength; i++)
{
mqttclient.write(configBuff[i]);
Expand All @@ -1041,7 +1041,7 @@ bool sendHaDiscovery()
sprintf(topBuff, "homeassistant/sensor/%s/Cell_%d_Voltage/config", _settings.data.mqttTopic, (i+1)); // build the topic
mqttContentLength = sprintf(configBuff, "{\"state_topic\": \"%s/Pack_Cells_Voltage/Cell_%d\",\"unique_id\": \"sensor.%s_CellV_%d\",\"name\": \"Cell_Voltage_%d\",\"icon\": \"mdi:flash-triangle-outline\",\"unit_of_measurement\": \"V\",\"device_class\":\"voltage\",\"device\":{\"identifiers\":[\"%06X\"], \"configuration_url\":\"http://%s\",\"name\":\"%s\", \"model\":\"Daly2MQTT\",\"manufacturer\":\"SoftWareCrash\",\"sw_version\":\"Solar2MQTT %s\"}}",
_settings.data.mqttTopic, (i+1), _settings.data.deviceName, (i+1), (i+1), ESP.getChipId(), (const char *)(WiFi.localIP().toString()).c_str(), _settings.data.deviceName, SOFTWARE_VERSION);
mqttclient.beginPublish(topBuff, mqttContentLength, false);
mqttclient.beginPublish(topBuff, mqttContentLength, true);
for (size_t i = 0; i < mqttContentLength; i++)
{
mqttclient.write(configBuff[i]);
Expand All @@ -1051,7 +1051,7 @@ bool sendHaDiscovery()
sprintf(topBuff, "homeassistant/sensor/%s/Cell_%d_Balance/config", _settings.data.mqttTopic, (i+1)); // build the topic
mqttContentLength = sprintf(configBuff, "{\"state_topic\": \"%s/Pack_Cells_Ballance/Cell_%d\",\"unique_id\": \"sensor.%s_CellB_%d\",\"name\": \"Cell_balance_%d\",\"icon\": \"mdi:scale-balance\",\"unit_of_measurement\": \"\",\"device_class\":\"\",\"device\":{\"identifiers\":[\"%06X\"], \"configuration_url\":\"http://%s\",\"name\":\"%s\", \"model\":\"Daly2MQTT\",\"manufacturer\":\"SoftWareCrash\",\"sw_version\":\"Solar2MQTT %s\"}}",
_settings.data.mqttTopic, (i+1), _settings.data.deviceName, (i+1), (i+1), ESP.getChipId(), (const char *)(WiFi.localIP().toString()).c_str(), _settings.data.deviceName, SOFTWARE_VERSION);
mqttclient.beginPublish(topBuff, mqttContentLength, false);
mqttclient.beginPublish(topBuff, mqttContentLength, true);
for (size_t i = 0; i < mqttContentLength; i++)
{
mqttclient.write(configBuff[i]);
Expand All @@ -1064,7 +1064,7 @@ bool sendHaDiscovery()
sprintf(topBuff, "homeassistant/sensor/%s/Pack_Cell_Temperature_%d/config", _settings.data.mqttTopic, (i+1)); // build the topic
mqttContentLength = sprintf(configBuff, "{\"state_topic\": \"%s/Pack_Cell_Temperature_%d\",\"unique_id\": \"sensor.%s_Pack_Cell_Temperature_%d\",\"name\": \"Pack_Cell_Temperature_%d\",\"icon\": \"mdi:thermometer-lines\",\"unit_of_measurement\": \"°C\",\"device_class\":\"temperature\",\"device\":{\"identifiers\":[\"%06X\"], \"configuration_url\":\"http://%s\",\"name\":\"%s\", \"model\":\"Daly2MQTT\",\"manufacturer\":\"SoftWareCrash\",\"sw_version\":\"Solar2MQTT %s\"}}",
_settings.data.mqttTopic, (i+1), _settings.data.deviceName, (i+1), (i+1), ESP.getChipId(), (const char *)(WiFi.localIP().toString()).c_str(), _settings.data.deviceName, SOFTWARE_VERSION);
mqttclient.beginPublish(topBuff, mqttContentLength, false);
mqttclient.beginPublish(topBuff, mqttContentLength, true);
for (size_t i = 0; i < mqttContentLength; i++)
{
mqttclient.write(configBuff[i]);
Expand All @@ -1078,7 +1078,7 @@ bool sendHaDiscovery()
sprintf(topBuff, "homeassistant/switch/%s/%s/config", _settings.data.mqttTopic, haControlDescriptor[i][0]); // build the topic
mqttContentLength = sprintf(configBuff, "{\"name\": \"%s\",\"command_topic\": \"%s/Device_Control/%s\",\"state_topic\": \"%s/%s\",\"unique_id\": \"%s.%s\",\"payload_on\": \"true\",\"payload_off\": \"false\",\"state_on\": \"true\",\"state_off\": \"false\",\"device\": {\"identifiers\": \"%06X\",\"name\": \"%s\",\"manufacturer\": \"SoftWareCrash\",\"configuration_url\": \"http://%s\",\"model\": \"Daly2MQTT\",\"sw_version\": \"%s\"}}",
haControlDescriptor[i][0], _settings.data.mqttTopic, haControlDescriptor[i][0], _settings.data.mqttTopic,haControlDescriptor[i][0], _settings.data.mqttTopic,haControlDescriptor[i][0], ESP.getChipId(), _settings.data.deviceName, (const char *)(WiFi.localIP().toString()).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]);
Expand Down

0 comments on commit b3afabb

Please sign in to comment.