Skip to content

Commit 355b71c

Browse files
committed
minor tidyups
1 parent c660440 commit 355b71c

File tree

6 files changed

+7
-10
lines changed

6 files changed

+7
-10
lines changed

src/dallassensor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ void DallasSensor::publish_values(const bool force) {
382382
JsonArray ids = dev.createNestedArray("ids");
383383
ids.add("ems-esp");
384384

385-
char topic[100];
385+
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
386386
if (dallas_format == Mqtt::Dallas_Format::SENSORID) {
387387
// use '_' as HA doesn't like '-' in the topic name
388388
std::string topicname = sensor.to_string();

src/devices/thermostat.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ void Thermostat::register_mqtt_ha_config_hc(uint8_t hc_num) {
377377
doc["temp_cmd_t"] = str3;
378378
doc["~"] = Mqtt::base(); // ems-esp
379379

380-
char topic_t[80];
380+
char topic_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
381381
if (Mqtt::nested_format()) {
382382
snprintf_P(topic_t, sizeof(topic_t), PSTR("~/%s"), Mqtt::tag_to_topic(EMSdevice::DeviceType::THERMOSTAT, DeviceValueTAG::TAG_NONE).c_str());
383383

@@ -428,7 +428,7 @@ void Thermostat::register_mqtt_ha_config_hc(uint8_t hc_num) {
428428
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
429429

430430
// enable the a special "thermostat_hc<n>" topic to take both mode strings and floats for each of the heating circuits
431-
std::string topic2(100, '\0');
431+
std::string topic2(Mqtt::MQTT_TOPIC_MAX_SIZE, '\0');
432432
snprintf_P(&topic2[0], topic2.capacity() + 1, PSTR("thermostat_hc%d"), hc_num);
433433
register_mqtt_topic(topic2, [=](const char * m) { return thermostat_ha_cmd(m, hc_num); });
434434

src/emsdevice.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ char * EMSdevice::show_telegram_handlers(char * result) {
352352

353353
char str[10];
354354
uint8_t i = 0;
355-
// for (const auto & tf : *telegram_functions_) {
356355
for (const auto & tf : telegram_functions_) {
357356
snprintf_P(str, sizeof(str), PSTR("0x%02X"), tf.telegram_type_id_);
358357
strlcat(result, str, 200);
@@ -572,8 +571,6 @@ bool EMSdevice::generate_values_json(JsonObject & root, const uint8_t tag_filter
572571
// we have a tag if it matches the filter given, and that the tag name is not empty/""
573572
bool have_tag = ((dv.tag != tag_filter) && !tag_to_string(dv.tag).empty());
574573

575-
// EMSESP::logger().info(F("**HERE: console=%d nested=%d tag_filter=%d tag=%d type=%d short=%s"), console, nested, tag_filter, dv.tag, dv.type, uuid::read_flash_string(dv.short_name).c_str());
576-
577574
char name[80];
578575
if (console) {
579576
// prefix the tag in brackets, unless it's Boiler because we're naughty and use tag for the MQTT topic

src/emsesp.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ void EMSESP::publish_device_values(uint8_t device_type) {
486486

487487
// publish it under a single topic, only if we have data to publish
488488
if (need_publish) {
489-
char topic[20];
489+
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
490490
snprintf_P(topic, sizeof(topic), PSTR("%s_data"), EMSdevice::device_type_2_device_name(device_type).c_str());
491491
Mqtt::publish(topic, json);
492492
}
@@ -688,7 +688,7 @@ void EMSESP::process_version(std::shared_ptr<const Telegram> telegram) {
688688
uint8_t product_id = telegram->message_data[offset]; // product ID
689689

690690
// get version as XX.XX
691-
std::string version(5, '\0');
691+
std::string version(6, '\0');
692692
snprintf_P(&version[0], version.capacity() + 1, PSTR("%02d.%02d"), telegram->message_data[offset + 1], telegram->message_data[offset + 2]);
693693

694694
// some devices store the protocol type (HT3, Buderus) in the last byte

src/emsesp.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
#define EMSESP_JSON_SIZE_XLARGE_DYN 4096 // for very very large json docs, using DynamicJsonDocument
6464
#define EMSESP_JSON_SIZE_XXLARGE_DYN 5120 // for extra very very large json docs, using DynamicJsonDocument
6565

66-
// helpers for call back functions
66+
// helpers for callback functions
6767
#define MAKE_PF_CB(__f) [&](std::shared_ptr<const Telegram> t) { __f(t); } // for process function callbacks to register_telegram_type()
6868
#define MAKE_CF_CB(__f) [&](const char * value, const int8_t id) { return __f(value, id); } // for command function callbacks to register_mqtt_cmd()
6969

src/shower.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void Shower::send_mqtt_stat(bool state, bool force) {
114114
JsonArray ids = dev.createNestedArray("ids");
115115
ids.add("ems-esp");
116116

117-
char topic[100];
117+
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
118118
snprintf_P(topic, sizeof(topic), PSTR("homeassistant/binary_sensor/%s/shower_active/config"), Mqtt::base().c_str());
119119
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
120120
}

0 commit comments

Comments
 (0)