minor tidyups

This commit is contained in:
proddy
2021-03-22 09:23:57 +01:00
parent c660440996
commit 355b71cacf
6 changed files with 7 additions and 10 deletions

View File

@@ -382,7 +382,7 @@ void DallasSensor::publish_values(const bool force) {
JsonArray ids = dev.createNestedArray("ids");
ids.add("ems-esp");
char topic[100];
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
if (dallas_format == Mqtt::Dallas_Format::SENSORID) {
// use '_' as HA doesn't like '-' in the topic name
std::string topicname = sensor.to_string();

View File

@@ -377,7 +377,7 @@ void Thermostat::register_mqtt_ha_config_hc(uint8_t hc_num) {
doc["temp_cmd_t"] = str3;
doc["~"] = Mqtt::base(); // ems-esp
char topic_t[80];
char topic_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
if (Mqtt::nested_format()) {
snprintf_P(topic_t, sizeof(topic_t), PSTR("~/%s"), Mqtt::tag_to_topic(EMSdevice::DeviceType::THERMOSTAT, DeviceValueTAG::TAG_NONE).c_str());
@@ -428,7 +428,7 @@ void Thermostat::register_mqtt_ha_config_hc(uint8_t hc_num) {
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
// enable the a special "thermostat_hc<n>" topic to take both mode strings and floats for each of the heating circuits
std::string topic2(100, '\0');
std::string topic2(Mqtt::MQTT_TOPIC_MAX_SIZE, '\0');
snprintf_P(&topic2[0], topic2.capacity() + 1, PSTR("thermostat_hc%d"), hc_num);
register_mqtt_topic(topic2, [=](const char * m) { return thermostat_ha_cmd(m, hc_num); });

View File

@@ -352,7 +352,6 @@ char * EMSdevice::show_telegram_handlers(char * result) {
char str[10];
uint8_t i = 0;
// for (const auto & tf : *telegram_functions_) {
for (const auto & tf : telegram_functions_) {
snprintf_P(str, sizeof(str), PSTR("0x%02X"), tf.telegram_type_id_);
strlcat(result, str, 200);
@@ -572,8 +571,6 @@ bool EMSdevice::generate_values_json(JsonObject & root, const uint8_t tag_filter
// we have a tag if it matches the filter given, and that the tag name is not empty/""
bool have_tag = ((dv.tag != tag_filter) && !tag_to_string(dv.tag).empty());
// 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());
char name[80];
if (console) {
// prefix the tag in brackets, unless it's Boiler because we're naughty and use tag for the MQTT topic

View File

@@ -486,7 +486,7 @@ void EMSESP::publish_device_values(uint8_t device_type) {
// publish it under a single topic, only if we have data to publish
if (need_publish) {
char topic[20];
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
snprintf_P(topic, sizeof(topic), PSTR("%s_data"), EMSdevice::device_type_2_device_name(device_type).c_str());
Mqtt::publish(topic, json);
}
@@ -688,7 +688,7 @@ void EMSESP::process_version(std::shared_ptr<const Telegram> telegram) {
uint8_t product_id = telegram->message_data[offset]; // product ID
// get version as XX.XX
std::string version(5, '\0');
std::string version(6, '\0');
snprintf_P(&version[0], version.capacity() + 1, PSTR("%02d.%02d"), telegram->message_data[offset + 1], telegram->message_data[offset + 2]);
// some devices store the protocol type (HT3, Buderus) in the last byte

View File

@@ -63,7 +63,7 @@
#define EMSESP_JSON_SIZE_XLARGE_DYN 4096 // for very very large json docs, using DynamicJsonDocument
#define EMSESP_JSON_SIZE_XXLARGE_DYN 5120 // for extra very very large json docs, using DynamicJsonDocument
// helpers for call back functions
// helpers for callback functions
#define MAKE_PF_CB(__f) [&](std::shared_ptr<const Telegram> t) { __f(t); } // for process function callbacks to register_telegram_type()
#define MAKE_CF_CB(__f) [&](const char * value, const int8_t id) { return __f(value, id); } // for command function callbacks to register_mqtt_cmd()

View File

@@ -114,7 +114,7 @@ void Shower::send_mqtt_stat(bool state, bool force) {
JsonArray ids = dev.createNestedArray("ids");
ids.add("ems-esp");
char topic[100];
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
snprintf_P(topic, sizeof(topic), PSTR("homeassistant/binary_sensor/%s/shower_active/config"), Mqtt::base().c_str());
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
}