Browse Source

0.8.84

* fix homeassistant autodiscovery #1432
pull/1475/head
lumapu 11 months ago
parent
commit
c7f7d77fb2
  1. 1300
      src/CHANGES.md
  2. 2
      src/defines.h
  3. 7
      src/publisher/pubMqtt.h

1300
src/CHANGES.md

File diff suppressed because it is too large

2
src/defines.h

@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 83
#define VERSION_PATCH 84
//-------------------------------------
typedef struct {

7
src/publisher/pubMqtt.h

@ -397,6 +397,10 @@ class PubMqtt {
std::array<char, 32> name;
std::array<char, 32> uniq_id;
std::array<char, 350> buf;
topic.fill(0);
name.fill(0);
uniq_id.fill(0);
buf.fill(0);
const char *devCls, *stateCls;
if (!total) {
if (rec->assign[mDiscovery.sub].ch == CH0)
@ -420,7 +424,7 @@ class PubMqtt {
DynamicJsonDocument doc2(512);
constexpr static char* unitTotal[] = {"W", "kWh", "Wh", "W"};
doc2[F("name")] = name;
doc2[F("name")] = String(name.data());
doc2[F("stat_t")] = String(mCfgMqtt->topic) + "/" + ((!total) ? String(iv->config->name) : "total" ) + String(topic.data());
doc2[F("unit_of_meas")] = ((!total) ? (iv->getUnit(mDiscovery.sub, rec)) : (unitTotal[mDiscovery.sub]));
doc2[F("uniq_id")] = ((!total) ? (String(iv->config->serial.u64, HEX)) : (node_id)) + "_" + uniq_id.data();
@ -437,7 +441,6 @@ class PubMqtt {
else // total values
snprintf(topic.data(), topic.size(), "%s/sensor/%s/total_%s/config", MQTT_DISCOVERY_PREFIX, node_id.c_str(), fields[fldTotal[mDiscovery.sub]]);
size_t size = measureJson(doc2) + 1;
buf.fill(0);
serializeJson(doc2, buf.data(), size);
publish(topic.data(), buf.data(), true, false);

Loading…
Cancel
Save