mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-13 15:37:03 +00:00
Fixed corrupted payload for HA
This commit is contained in:
parent
2ef1700cfe
commit
196b79e4c8
@ -214,41 +214,41 @@ bool HomeAssistantMqttHandler::publishSystem(HwTools* hw) {
|
||||
String haUrl = "http://" + haUID + ".local/";
|
||||
|
||||
for(int i=0;i<sensors;i++){
|
||||
if(strlen(HA_STACL[i]) > 0) { // TODO: reduce to single JSON, state_class: null (witout quotation). or make it some extra optional string that us appended
|
||||
if(strlen_P(HA_STACL[i]) > 0) { // TODO: reduce to single JSON, state_class: null (witout quotation). or make it some extra optional string that us appended
|
||||
snprintf_P(json, BufferSize, HADISCOVER2_JSON,
|
||||
HA_NAMES[i], // name
|
||||
(topic + HA_TOPICS[i]), // state_topic
|
||||
(haUID + "_" + HA_PARAMS[i]), // unique_id
|
||||
(haUID + "_" + HA_PARAMS[i]), // object_id
|
||||
HA_UOM[i], // unit_of_measurement
|
||||
HA_PARAMS[i], // value_template
|
||||
HA_DEVCL[i], // device_class
|
||||
haUID.c_str(), // dev ids
|
||||
haName.c_str(), // name
|
||||
haModel.c_str(), // model
|
||||
VERSION, // fw version
|
||||
haManuf.c_str(), // manufacturer
|
||||
haUrl.c_str(), // configuration_url
|
||||
HA_STACL[i] // state_class
|
||||
FPSTR(HA_NAMES[i]),
|
||||
topic, FPSTR(HA_TOPICS[i]),
|
||||
haUID, FPSTR(HA_PARAMS[i]),
|
||||
haUID, FPSTR(HA_PARAMS[i]),
|
||||
FPSTR(HA_UOM[i]),
|
||||
FPSTR(HA_PARAMS[i]),
|
||||
FPSTR(HA_DEVCL[i]),
|
||||
haUID.c_str(),
|
||||
haName.c_str(),
|
||||
haModel.c_str(),
|
||||
VERSION,
|
||||
haManuf.c_str(),
|
||||
haUrl.c_str(),
|
||||
FPSTR(HA_STACL[i])
|
||||
);
|
||||
} else {
|
||||
snprintf_P(json, BufferSize, HADISCOVER1_JSON,
|
||||
HA_NAMES[i], // name
|
||||
(topic + HA_TOPICS[i]).c_str(), // state_topic
|
||||
(haUID + "_" + HA_PARAMS[i]).c_str(), // unique_id
|
||||
(haUID + "_" + HA_PARAMS[i]).c_str(), // object_id
|
||||
HA_UOM[i], // unit_of_measurement
|
||||
HA_PARAMS[i], // value_template
|
||||
HA_DEVCL[i], // device_class
|
||||
haUID.c_str(), // dev ids
|
||||
haName.c_str(), // name
|
||||
haModel.c_str(), // model
|
||||
VERSION, // fw version
|
||||
haManuf.c_str(), // manufacturer
|
||||
haUrl.c_str() // configuration_url
|
||||
FPSTR(HA_NAMES[i]),
|
||||
topic, FPSTR(HA_TOPICS[i]),
|
||||
haUID, FPSTR(HA_PARAMS[i]),
|
||||
haUID, FPSTR(HA_PARAMS[i]),
|
||||
FPSTR(HA_UOM[i]),
|
||||
FPSTR(HA_PARAMS[i]),
|
||||
FPSTR(HA_DEVCL[i]),
|
||||
haUID.c_str(),
|
||||
haName.c_str(),
|
||||
haModel.c_str(),
|
||||
VERSION,
|
||||
haManuf.c_str(),
|
||||
haUrl.c_str()
|
||||
);
|
||||
}
|
||||
mqtt->publish(haTopic + haUID + "_" + HA_PARAMS[i] + "/config", json, true, 0);
|
||||
mqtt->publish(haTopic + haUID + "_" + FPSTR(HA_PARAMS[i]) + "/config", json, true, 0);
|
||||
}
|
||||
autodiscoverInit = true;
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name" : "%s",
|
||||
"stat_t" : "%s",
|
||||
"uniq_id" : "%s",
|
||||
"obj_id" : "%s",
|
||||
"stat_t" : "%s%s",
|
||||
"uniq_id" : "%s_%s",
|
||||
"obj_id" : "%s_%s",
|
||||
"unit_of_meas" : "%s",
|
||||
"val_tpl" : "{{value_json['%s']}}",
|
||||
"dev_cla" : "%s",
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name" : "%s",
|
||||
"stat_t" : "%s",
|
||||
"uniq_id" : "%s",
|
||||
"obj_id" : "%s",
|
||||
"stat_t" : "%s%s",
|
||||
"uniq_id" : "%s_%s",
|
||||
"obj_id" : "%s_%s",
|
||||
"unit_of_meas" : "%s",
|
||||
"val_tpl" : "{{value_json['%s']}}",
|
||||
"dev_cla" : "%s",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user