mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
remove PSTR()
This commit is contained in:
@@ -4,12 +4,14 @@
|
|||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
|
||||||
- add system commands for syslog level and watch [#98](https://github.com/emsesp/EMS-ESP32/issues/98)
|
- Add system commands for syslog level and watch [#98](https://github.com/emsesp/EMS-ESP32/issues/98)
|
||||||
- Added pool data to telegrams 0x494 & 0x495 #102 [#102](https://github.com/emsesp/EMS-ESP32/issues/102) (@Sunbuzz)
|
- Added pool data to telegrams 0x494 & 0x495 #102 [#102](https://github.com/emsesp/EMS-ESP32/issues/102) (@Sunbuzz)
|
||||||
|
- Add RC300 second summermode telegram [#108](https://github.com/emsesp/EMS-ESP32/issues/108)
|
||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
- MQTT reconnecting after WiFi reconnect [#99](https://github.com/emsesp/EMS-ESP32/issues/99)
|
- MQTT reconnecting after WiFi reconnect [#99](https://github.com/emsesp/EMS-ESP32/issues/99)
|
||||||
|
- Manually Controlling Solar Circuit [#107](https://github.com/emsesp/EMS-ESP32/issues/107)
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ void EMSESPShell::display_banner() {
|
|||||||
|
|
||||||
if (console_hostname_.empty()) {
|
if (console_hostname_.empty()) {
|
||||||
console_hostname_.resize(16, '\0');
|
console_hostname_.resize(16, '\0');
|
||||||
snprintf_P(&console_hostname_[0], console_hostname_.capacity() + 1, PSTR("ems-esp"));
|
snprintf_P(&console_hostname_[0], console_hostname_.capacity() + 1, "ems-esp");
|
||||||
}
|
}
|
||||||
|
|
||||||
// load the list of commands
|
// load the list of commands
|
||||||
@@ -841,7 +841,7 @@ EMSESPStreamConsole::EMSESPStreamConsole(Stream & stream, const IPAddress & addr
|
|||||||
ptys_[pty_] = true;
|
ptys_[pty_] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf_P(text.data(), text.size(), PSTR("pty%u"), pty_);
|
snprintf_P(text.data(), text.size(), "pty%u", pty_);
|
||||||
name_ = text.data();
|
name_ = text.data();
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
logger().info(F("Allocated console %s for connection from [%s]:%u"), name_.c_str(), uuid::printable_to_string(addr_).c_str(), port_);
|
logger().info(F("Allocated console %s for connection from [%s]:%u"), name_.c_str(), uuid::printable_to_string(addr_).c_str(), port_);
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ std::string DallasSensor::Sensor::id_string() const {
|
|||||||
std::string str(20, '\0');
|
std::string str(20, '\0');
|
||||||
snprintf_P(&str[0],
|
snprintf_P(&str[0],
|
||||||
str.capacity() + 1,
|
str.capacity() + 1,
|
||||||
PSTR("%02X-%04X-%04X-%04X"),
|
"%02X-%04X-%04X-%04X",
|
||||||
(unsigned int)(id_ >> 48) & 0xFF,
|
(unsigned int)(id_ >> 48) & 0xFF,
|
||||||
(unsigned int)(id_ >> 32) & 0xFFFF,
|
(unsigned int)(id_ >> 32) & 0xFFFF,
|
||||||
(unsigned int)(id_ >> 16) & 0xFFFF,
|
(unsigned int)(id_ >> 16) & 0xFFFF,
|
||||||
@@ -347,7 +347,7 @@ void DallasSensor::delete_ha_config(uint8_t index, const char * name) {
|
|||||||
std::string topicname = name;
|
std::string topicname = name;
|
||||||
std::replace(topicname.begin(), topicname.end(), '-', '_');
|
std::replace(topicname.begin(), topicname.end(), '-', '_');
|
||||||
|
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("homeassistant/sensor/%s/dallassensor_%s/config"), Mqtt::base().c_str(), topicname.c_str());
|
snprintf_P(topic, sizeof(topic), "homeassistant/sensor/%s/dallassensor_%s/config", Mqtt::base().c_str(), topicname.c_str());
|
||||||
Mqtt::publish(topic);
|
Mqtt::publish(topic);
|
||||||
registered_ha_[index] = false; // forces a recreate of the HA config topic
|
registered_ha_[index] = false; // forces a recreate of the HA config topic
|
||||||
}
|
}
|
||||||
@@ -461,7 +461,7 @@ bool DallasSensor::command_info(const char * value, const int8_t id, JsonObject
|
|||||||
uint8_t i = 1; // sensor count
|
uint8_t i = 1; // sensor count
|
||||||
for (const auto & sensor : sensors_) {
|
for (const auto & sensor : sensors_) {
|
||||||
char sensorID[10]; // sensor{1-n}
|
char sensorID[10]; // sensor{1-n}
|
||||||
snprintf_P(sensorID, 10, PSTR("sensor%d"), i++);
|
snprintf_P(sensorID, 10, "sensor%d", i++);
|
||||||
if (id == -1) { // show number and id
|
if (id == -1) { // show number and id
|
||||||
JsonObject dataSensor = json.createNestedObject(sensorID);
|
JsonObject dataSensor = json.createNestedObject(sensorID);
|
||||||
dataSensor["id"] = sensor.to_string();
|
dataSensor["id"] = sensor.to_string();
|
||||||
@@ -493,7 +493,7 @@ void DallasSensor::publish_values(const bool force) {
|
|||||||
|
|
||||||
for (const auto & sensor : sensors_) {
|
for (const auto & sensor : sensors_) {
|
||||||
char sensorID[10]; // sensor{1-n}
|
char sensorID[10]; // sensor{1-n}
|
||||||
snprintf_P(sensorID, 10, PSTR("sensor%d"), sensor_no);
|
snprintf_P(sensorID, 10, "sensor%d", sensor_no);
|
||||||
if (dallas_format_ == Dallas_Format::NUMBER) {
|
if (dallas_format_ == Dallas_Format::NUMBER) {
|
||||||
// e.g. dallassensor_data = {"sensor1":{"id":"28-EA41-9497-0E03","temp":23.3},"sensor2":{"id":"28-233D-9497-0C03","temp":24.0}}
|
// e.g. dallassensor_data = {"sensor1":{"id":"28-EA41-9497-0E03","temp":23.3},"sensor2":{"id":"28-233D-9497-0C03","temp":24.0}}
|
||||||
JsonObject dataSensor = doc.createNestedObject(sensorID);
|
JsonObject dataSensor = doc.createNestedObject(sensorID);
|
||||||
@@ -513,28 +513,28 @@ void DallasSensor::publish_values(const bool force) {
|
|||||||
config["dev_cla"] = FJSON("temperature");
|
config["dev_cla"] = FJSON("temperature");
|
||||||
|
|
||||||
char stat_t[50];
|
char stat_t[50];
|
||||||
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/dallassensor_data"), Mqtt::base().c_str());
|
snprintf_P(stat_t, sizeof(stat_t), "%s/dallassensor_data", Mqtt::base().c_str());
|
||||||
config["stat_t"] = stat_t;
|
config["stat_t"] = stat_t;
|
||||||
|
|
||||||
config["unit_of_meas"] = FJSON("°C");
|
config["unit_of_meas"] = FJSON("°C");
|
||||||
|
|
||||||
char str[50];
|
char str[50];
|
||||||
if (dallas_format_ != Dallas_Format::NUMBER) {
|
if (dallas_format_ != Dallas_Format::NUMBER) {
|
||||||
snprintf_P(str, sizeof(str), PSTR("{{value_json['%s']}}"), sensor.to_string().c_str());
|
snprintf_P(str, sizeof(str), "{{value_json['%s']}}", sensor.to_string().c_str());
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(str, sizeof(str), PSTR("{{value_json.sensor%d.temp}}"), sensor_no);
|
snprintf_P(str, sizeof(str), "{{value_json.sensor%d.temp}}", sensor_no);
|
||||||
}
|
}
|
||||||
config["val_tpl"] = str;
|
config["val_tpl"] = str;
|
||||||
|
|
||||||
// name as sensor number not the long unique ID
|
// name as sensor number not the long unique ID
|
||||||
if (dallas_format_ != Dallas_Format::NUMBER) {
|
if (dallas_format_ != Dallas_Format::NUMBER) {
|
||||||
snprintf_P(str, sizeof(str), PSTR("Dallas Sensor %s"), sensor.to_string().c_str());
|
snprintf_P(str, sizeof(str), "Dallas Sensor %s", sensor.to_string().c_str());
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(str, sizeof(str), PSTR("Dallas Sensor %d"), sensor_no);
|
snprintf_P(str, sizeof(str), "Dallas Sensor %d", sensor_no);
|
||||||
}
|
}
|
||||||
config["name"] = str;
|
config["name"] = str;
|
||||||
|
|
||||||
snprintf_P(str, sizeof(str), PSTR("dallasensor_%s"), sensor.to_string().c_str());
|
snprintf_P(str, sizeof(str), "dallasensor_%s", sensor.to_string().c_str());
|
||||||
config["uniq_id"] = str;
|
config["uniq_id"] = str;
|
||||||
|
|
||||||
JsonObject dev = config.createNestedObject("dev");
|
JsonObject dev = config.createNestedObject("dev");
|
||||||
@@ -543,12 +543,12 @@ void DallasSensor::publish_values(const bool force) {
|
|||||||
|
|
||||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
if (dallas_format_ == Dallas_Format::NUMBER) {
|
if (dallas_format_ == Dallas_Format::NUMBER) {
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("sensor/%s/dallassensor_%d/config"), Mqtt::base().c_str(), sensor_no);
|
snprintf_P(topic, sizeof(topic), "sensor/%s/dallassensor_%d/config", Mqtt::base().c_str(), sensor_no);
|
||||||
} else {
|
} else {
|
||||||
// use '_' as HA doesn't like '-' in the topic name
|
// use '_' as HA doesn't like '-' in the topic name
|
||||||
std::string topicname = sensor.to_string();
|
std::string topicname = sensor.to_string();
|
||||||
std::replace(topicname.begin(), topicname.end(), '-', '_');
|
std::replace(topicname.begin(), topicname.end(), '-', '_');
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("sensor/%s/dallassensor_%s/config"), Mqtt::base().c_str(), topicname.c_str());
|
snprintf_P(topic, sizeof(topic), "sensor/%s/dallassensor_%s/config", Mqtt::base().c_str(), topicname.c_str());
|
||||||
}
|
}
|
||||||
Mqtt::publish_ha(topic, config.as<JsonObject>());
|
Mqtt::publish_ha(topic, config.as<JsonObject>());
|
||||||
|
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ bool Boiler::publish_ha_config() {
|
|||||||
doc["ic"] = F_(icondevice);
|
doc["ic"] = F_(icondevice);
|
||||||
|
|
||||||
char stat_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char stat_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/%s"), Mqtt::base().c_str(), Mqtt::tag_to_topic(device_type(), DeviceValueTAG::TAG_NONE).c_str());
|
snprintf_P(stat_t, sizeof(stat_t), "%s/%s", Mqtt::base().c_str(), Mqtt::tag_to_topic(device_type(), DeviceValueTAG::TAG_NONE).c_str());
|
||||||
doc["stat_t"] = stat_t;
|
doc["stat_t"] = stat_t;
|
||||||
|
|
||||||
char name_s[40];
|
char name_s[40];
|
||||||
@@ -304,7 +304,7 @@ bool Boiler::publish_ha_config() {
|
|||||||
ids.add("ems-esp-boiler");
|
ids.add("ems-esp-boiler");
|
||||||
|
|
||||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("sensor/%s/boiler/config"), Mqtt::base().c_str());
|
snprintf_P(topic, sizeof(topic), "sensor/%s/boiler/config", Mqtt::base().c_str());
|
||||||
Mqtt::publish_ha(topic,
|
Mqtt::publish_ha(topic,
|
||||||
doc.as<JsonObject>()); // publish the config payload with retain flag
|
doc.as<JsonObject>()); // publish the config payload with retain flag
|
||||||
|
|
||||||
@@ -791,7 +791,7 @@ void Boiler::process_UBAMaintenanceStatus(std::shared_ptr<const Telegram> telegr
|
|||||||
|
|
||||||
// ignore if 0, which means all is ok
|
// ignore if 0, which means all is ok
|
||||||
if (Helpers::hasValue(message_code) && message_code > 0) {
|
if (Helpers::hasValue(message_code) && message_code > 0) {
|
||||||
snprintf_P(maintenanceMessage_, sizeof(maintenanceMessage_), PSTR("H%02d"), message_code);
|
snprintf_P(maintenanceMessage_, sizeof(maintenanceMessage_), "H%02d", message_code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -818,7 +818,7 @@ void Boiler::process_UBAErrorMessage(std::shared_ptr<const Telegram> telegram) {
|
|||||||
uint32_t date = (year - 2000) * 535680UL + month * 44640UL + day * 1440UL + hour * 60 + min;
|
uint32_t date = (year - 2000) * 535680UL + month * 44640UL + day * 1440UL + hour * 60 + min;
|
||||||
// store only the newest code from telegrams 10 and 11
|
// store only the newest code from telegrams 10 and 11
|
||||||
if (date > lastCodeDate_) {
|
if (date > lastCodeDate_) {
|
||||||
snprintf_P(lastCode_, sizeof(lastCode_), PSTR("%s(%d) %02d.%02d.%d %02d:%02d"), code, codeNo, day, month, year, hour, min);
|
snprintf_P(lastCode_, sizeof(lastCode_), "%s(%d) %02d.%02d.%d %02d:%02d", code, codeNo, day, month, year, hour, min);
|
||||||
lastCodeDate_ = date;
|
lastCodeDate_ = date;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -844,7 +844,7 @@ void Boiler::process_UBAMaintenanceData(std::shared_ptr<const Telegram> telegram
|
|||||||
uint8_t month = telegram->message_data[3];
|
uint8_t month = telegram->message_data[3];
|
||||||
uint8_t year = telegram->message_data[4];
|
uint8_t year = telegram->message_data[4];
|
||||||
if (day > 0 && month > 0) {
|
if (day > 0 && month > 0) {
|
||||||
snprintf_P(maintenanceDate_, sizeof(maintenanceDate_), PSTR("%02d.%02d.%04d"), day, month, year + 2000);
|
snprintf_P(maintenanceDate_, sizeof(maintenanceDate_), "%02d.%02d.%04d", day, month, year + 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ bool Heatpump::publish_ha_config() {
|
|||||||
doc["ic"] = F_(icondevice);
|
doc["ic"] = F_(icondevice);
|
||||||
|
|
||||||
char stat_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char stat_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/%s"), Mqtt::base().c_str(), Mqtt::tag_to_topic(device_type(), DeviceValueTAG::TAG_NONE).c_str());
|
snprintf_P(stat_t, sizeof(stat_t), "%s/%s", Mqtt::base().c_str(), Mqtt::tag_to_topic(device_type(), DeviceValueTAG::TAG_NONE).c_str());
|
||||||
doc["stat_t"] = stat_t;
|
doc["stat_t"] = stat_t;
|
||||||
|
|
||||||
char name_s[40];
|
char name_s[40];
|
||||||
@@ -64,7 +64,7 @@ bool Heatpump::publish_ha_config() {
|
|||||||
ids.add("ems-esp-heatpump");
|
ids.add("ems-esp-heatpump");
|
||||||
|
|
||||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("sensor/%s/heatpump/config"), Mqtt::base().c_str());
|
snprintf_P(topic, sizeof(topic), "sensor/%s/heatpump/config", Mqtt::base().c_str());
|
||||||
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ uuid::log::Logger Mixer::logger_{F_(mixer), uuid::log::Facility::CONSOLE};
|
|||||||
|
|
||||||
Mixer::Mixer(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand)
|
Mixer::Mixer(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand)
|
||||||
: EMSdevice(device_type, device_id, product_id, version, name, flags, brand) {
|
: EMSdevice(device_type, device_id, product_id, version, name, flags, brand) {
|
||||||
|
|
||||||
LOG_DEBUG(F("Adding new Mixer with device ID 0x%02X"), device_id);
|
LOG_DEBUG(F("Adding new Mixer with device ID 0x%02X"), device_id);
|
||||||
|
|
||||||
// Pool module
|
// Pool module
|
||||||
@@ -111,23 +110,23 @@ bool Mixer::publish_ha_config() {
|
|||||||
|
|
||||||
char uniq_id[20];
|
char uniq_id[20];
|
||||||
if (type_ == Type::MP) {
|
if (type_ == Type::MP) {
|
||||||
snprintf_P(uniq_id, sizeof(uniq_id), PSTR("MixerMP"));
|
snprintf_P(uniq_id, sizeof(uniq_id), "MixerMP");
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(uniq_id, sizeof(uniq_id), PSTR("Mixer%02X"), device_id() - 0x20 + 1);
|
snprintf_P(uniq_id, sizeof(uniq_id), "Mixer%02X", device_id() - 0x20 + 1);
|
||||||
}
|
}
|
||||||
doc["uniq_id"] = uniq_id;
|
doc["uniq_id"] = uniq_id;
|
||||||
|
|
||||||
doc["ic"] = F_(icondevice);
|
doc["ic"] = F_(icondevice);
|
||||||
|
|
||||||
char stat_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char stat_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/%s"), Mqtt::base().c_str(), Mqtt::tag_to_topic(device_type(), DeviceValueTAG::TAG_NONE).c_str());
|
snprintf_P(stat_t, sizeof(stat_t), "%s/%s", Mqtt::base().c_str(), Mqtt::tag_to_topic(device_type(), DeviceValueTAG::TAG_NONE).c_str());
|
||||||
doc["stat_t"] = stat_t;
|
doc["stat_t"] = stat_t;
|
||||||
|
|
||||||
char name[20];
|
char name[20];
|
||||||
if (type_ == Type::MP) {
|
if (type_ == Type::MP) {
|
||||||
snprintf_P(name, sizeof(name), PSTR("Mixer MP"));
|
snprintf_P(name, sizeof(name), "Mixer MP");
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(name, sizeof(name), PSTR("Mixer %02X"), device_id() - 0x20 + 1);
|
snprintf_P(name, sizeof(name), "Mixer %02X", device_id() - 0x20 + 1);
|
||||||
}
|
}
|
||||||
doc["name"] = name;
|
doc["name"] = name;
|
||||||
|
|
||||||
@@ -152,11 +151,11 @@ bool Mixer::publish_ha_config() {
|
|||||||
// determine the topic, if its HC and WWC. This is determined by the incoming telegram types.
|
// determine the topic, if its HC and WWC. This is determined by the incoming telegram types.
|
||||||
std::string topic(Mqtt::MQTT_TOPIC_MAX_SIZE, '\0');
|
std::string topic(Mqtt::MQTT_TOPIC_MAX_SIZE, '\0');
|
||||||
if (type_ == Type::HC) {
|
if (type_ == Type::HC) {
|
||||||
snprintf_P(&topic[0], topic.capacity() + 1, PSTR("sensor/%s/mixer_hc%d/config"), Mqtt::base().c_str(), hc_);
|
snprintf_P(&topic[0], topic.capacity() + 1, "sensor/%s/mixer_hc%d/config", Mqtt::base().c_str(), hc_);
|
||||||
} else if (type_ == Type::WWC) {
|
} else if (type_ == Type::WWC) {
|
||||||
snprintf_P(&topic[0], topic.capacity() + 1, PSTR("sensor/%s/mixer_wwc%d/config"), Mqtt::base().c_str(), hc_); // WWC
|
snprintf_P(&topic[0], topic.capacity() + 1, "sensor/%s/mixer_wwc%d/config", Mqtt::base().c_str(), hc_); // WWC
|
||||||
} else if (type_ == Type::MP) {
|
} else if (type_ == Type::MP) {
|
||||||
snprintf_P(&topic[0], topic.capacity() + 1, PSTR("sensor/%s/mixer_mp/config"), Mqtt::base().c_str());
|
snprintf_P(&topic[0], topic.capacity() + 1, "sensor/%s/mixer_mp/config", Mqtt::base().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
||||||
@@ -272,7 +271,7 @@ bool Mixer::set_flowSetTemp(const char * value, const int8_t id) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (flags() == EMSdevice::EMS_DEVICE_FLAG_MMPLUS) {
|
if (flags() == EMSdevice::EMS_DEVICE_FLAG_MMPLUS) {
|
||||||
uint8_t hc = device_id() -0x20;
|
uint8_t hc = device_id() - 0x20;
|
||||||
write_command(0x2E1 + hc, 1, v, 0x2D7 + hc);
|
write_command(0x2E1 + hc, 1, v, 0x2D7 + hc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,8 +109,13 @@ Solar::Solar(uint8_t device_type, uint8_t device_id, uint8_t product_id, const s
|
|||||||
register_device_value(TAG_NONE, &solarPumpMinMod_, DeviceValueType::UINT, nullptr, FL_(pumpMinMod), DeviceValueUOM::PERCENT, MAKE_CF_CB(set_PumpMinMod));
|
register_device_value(TAG_NONE, &solarPumpMinMod_, DeviceValueType::UINT, nullptr, FL_(pumpMinMod), DeviceValueUOM::PERCENT, MAKE_CF_CB(set_PumpMinMod));
|
||||||
register_device_value(
|
register_device_value(
|
||||||
TAG_NONE, &solarPumpTurnonDiff_, DeviceValueType::UINT, FL_(div10), FL_(solarPumpTurnonDiff), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_TurnonDiff));
|
TAG_NONE, &solarPumpTurnonDiff_, DeviceValueType::UINT, FL_(div10), FL_(solarPumpTurnonDiff), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_TurnonDiff));
|
||||||
register_device_value(
|
register_device_value(TAG_NONE,
|
||||||
TAG_NONE, &solarPumpTurnoffDiff_, DeviceValueType::UINT, FL_(div10), FL_(solarPumpTurnoffDiff), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_TurnoffDiff));
|
&solarPumpTurnoffDiff_,
|
||||||
|
DeviceValueType::UINT,
|
||||||
|
FL_(div10),
|
||||||
|
FL_(solarPumpTurnoffDiff),
|
||||||
|
DeviceValueUOM::DEGREES,
|
||||||
|
MAKE_CF_CB(set_TurnoffDiff));
|
||||||
register_device_value(TAG_NONE, &tankBottomTemp2_, DeviceValueType::SHORT, FL_(div10), FL_(tank2BottomTemp), DeviceValueUOM::DEGREES);
|
register_device_value(TAG_NONE, &tankBottomTemp2_, DeviceValueType::SHORT, FL_(div10), FL_(tank2BottomTemp), DeviceValueUOM::DEGREES);
|
||||||
register_device_value(TAG_NONE, &heatExchangerTemp_, DeviceValueType::SHORT, FL_(div10), FL_(heatExchangerTemp), DeviceValueUOM::DEGREES);
|
register_device_value(TAG_NONE, &heatExchangerTemp_, DeviceValueType::SHORT, FL_(div10), FL_(heatExchangerTemp), DeviceValueUOM::DEGREES);
|
||||||
register_device_value(TAG_NONE, &cylinderPumpModulation_, DeviceValueType::UINT, nullptr, FL_(cylinderPumpModulation), DeviceValueUOM::PERCENT);
|
register_device_value(TAG_NONE, &cylinderPumpModulation_, DeviceValueType::UINT, nullptr, FL_(cylinderPumpModulation), DeviceValueUOM::PERCENT);
|
||||||
@@ -189,7 +194,7 @@ bool Solar::publish_ha_config() {
|
|||||||
doc["ic"] = F_(icondevice);
|
doc["ic"] = F_(icondevice);
|
||||||
|
|
||||||
char stat_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char stat_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/%s"), Mqtt::base().c_str(), Mqtt::tag_to_topic(device_type(), DeviceValueTAG::TAG_NONE).c_str());
|
snprintf_P(stat_t, sizeof(stat_t), "%s/%s", Mqtt::base().c_str(), Mqtt::tag_to_topic(device_type(), DeviceValueTAG::TAG_NONE).c_str());
|
||||||
doc["stat_t"] = stat_t;
|
doc["stat_t"] = stat_t;
|
||||||
|
|
||||||
char name_s[40];
|
char name_s[40];
|
||||||
@@ -206,7 +211,7 @@ bool Solar::publish_ha_config() {
|
|||||||
ids.add("ems-esp-solar");
|
ids.add("ems-esp-solar");
|
||||||
|
|
||||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("sensor/%s/solar/config"), Mqtt::base().c_str());
|
snprintf_P(topic, sizeof(topic), "sensor/%s/solar/config", Mqtt::base().c_str());
|
||||||
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ bool Switch::publish_ha_config() {
|
|||||||
doc["ic"] = F_(icondevice);
|
doc["ic"] = F_(icondevice);
|
||||||
|
|
||||||
char stat_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char stat_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/%s"), Mqtt::base().c_str(), Mqtt::tag_to_topic(device_type(), DeviceValueTAG::TAG_NONE).c_str());
|
snprintf_P(stat_t, sizeof(stat_t), "%s/%s", Mqtt::base().c_str(), Mqtt::tag_to_topic(device_type(), DeviceValueTAG::TAG_NONE).c_str());
|
||||||
doc["stat_t"] = stat_t;
|
doc["stat_t"] = stat_t;
|
||||||
|
|
||||||
char name_s[40];
|
char name_s[40];
|
||||||
@@ -70,7 +70,7 @@ bool Switch::publish_ha_config() {
|
|||||||
ids.add("ems-esp-switch");
|
ids.add("ems-esp-switch");
|
||||||
|
|
||||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("sensor/%s/switch/config"), Mqtt::base().c_str());
|
snprintf_P(topic, sizeof(topic), "sensor/%s/switch/config", Mqtt::base().c_str());
|
||||||
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ bool Thermostat::publish_ha_config() {
|
|||||||
doc["ic"] = F_(icondevice);
|
doc["ic"] = F_(icondevice);
|
||||||
|
|
||||||
char stat_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char stat_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/%s"), Mqtt::base().c_str(), Mqtt::tag_to_topic(device_type(), DeviceValueTAG::TAG_NONE).c_str());
|
snprintf_P(stat_t, sizeof(stat_t), "%s/%s", Mqtt::base().c_str(), Mqtt::tag_to_topic(device_type(), DeviceValueTAG::TAG_NONE).c_str());
|
||||||
doc["stat_t"] = stat_t;
|
doc["stat_t"] = stat_t;
|
||||||
|
|
||||||
char name_s[40];
|
char name_s[40];
|
||||||
@@ -219,7 +219,7 @@ bool Thermostat::publish_ha_config() {
|
|||||||
ids.add("ems-esp-thermostat");
|
ids.add("ems-esp-thermostat");
|
||||||
|
|
||||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("sensor/%s/thermostat/config"), Mqtt::base().c_str());
|
snprintf_P(topic, sizeof(topic), "sensor/%s/thermostat/config", Mqtt::base().c_str());
|
||||||
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -385,13 +385,13 @@ void Thermostat::publish_ha_config_hc(uint8_t hc_num) {
|
|||||||
StaticJsonDocument<EMSESP_JSON_SIZE_HA_CONFIG> doc;
|
StaticJsonDocument<EMSESP_JSON_SIZE_HA_CONFIG> doc;
|
||||||
|
|
||||||
char str1[20];
|
char str1[20];
|
||||||
snprintf_P(str1, sizeof(str1), PSTR("Thermostat hc%d"), hc_num);
|
snprintf_P(str1, sizeof(str1), "Thermostat hc%d", hc_num);
|
||||||
|
|
||||||
char str2[20];
|
char str2[20];
|
||||||
snprintf_P(str2, sizeof(str2), PSTR("thermostat_hc%d"), hc_num);
|
snprintf_P(str2, sizeof(str2), "thermostat_hc%d", hc_num);
|
||||||
|
|
||||||
char str3[25];
|
char str3[25];
|
||||||
snprintf_P(str3, sizeof(str3), PSTR("~/%s"), str2);
|
snprintf_P(str3, sizeof(str3), "~/%s", str2);
|
||||||
doc["mode_cmd_t"] = str3;
|
doc["mode_cmd_t"] = str3;
|
||||||
doc["temp_cmd_t"] = str3;
|
doc["temp_cmd_t"] = str3;
|
||||||
doc["name"] = str1;
|
doc["name"] = str1;
|
||||||
@@ -402,23 +402,23 @@ void Thermostat::publish_ha_config_hc(uint8_t hc_num) {
|
|||||||
|
|
||||||
char topic_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char topic_t[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
if (Mqtt::nested_format() == 1) {
|
if (Mqtt::nested_format() == 1) {
|
||||||
snprintf_P(topic_t, sizeof(topic_t), PSTR("~/%s"), Mqtt::tag_to_topic(EMSdevice::DeviceType::THERMOSTAT, DeviceValueTAG::TAG_NONE).c_str());
|
snprintf_P(topic_t, sizeof(topic_t), "~/%s", Mqtt::tag_to_topic(EMSdevice::DeviceType::THERMOSTAT, DeviceValueTAG::TAG_NONE).c_str());
|
||||||
|
|
||||||
char mode_str_tpl[40];
|
char mode_str_tpl[40];
|
||||||
snprintf_P(mode_str_tpl, sizeof(mode_str_tpl), PSTR("{{value_json.hc%d.hamode}}"), hc_num);
|
snprintf_P(mode_str_tpl, sizeof(mode_str_tpl), "{{value_json.hc%d.hamode}}", hc_num);
|
||||||
doc["mode_stat_tpl"] = mode_str_tpl;
|
doc["mode_stat_tpl"] = mode_str_tpl;
|
||||||
|
|
||||||
char seltemp_str[30];
|
char seltemp_str[30];
|
||||||
snprintf_P(seltemp_str, sizeof(seltemp_str), PSTR("{{value_json.hc%d.seltemp}}"), hc_num);
|
snprintf_P(seltemp_str, sizeof(seltemp_str), "{{value_json.hc%d.seltemp}}", hc_num);
|
||||||
doc["temp_stat_tpl"] = seltemp_str;
|
doc["temp_stat_tpl"] = seltemp_str;
|
||||||
|
|
||||||
char currtemp_str[30];
|
char currtemp_str[30];
|
||||||
snprintf_P(currtemp_str, sizeof(currtemp_str), PSTR("{{value_json.hc%d.hatemp}}"), hc_num);
|
snprintf_P(currtemp_str, sizeof(currtemp_str), "{{value_json.hc%d.hatemp}}", hc_num);
|
||||||
doc["curr_temp_tpl"] = currtemp_str;
|
doc["curr_temp_tpl"] = currtemp_str;
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(topic_t, sizeof(topic_t), PSTR("~/%s"), Mqtt::tag_to_topic(EMSdevice::DeviceType::THERMOSTAT, DeviceValueTAG::TAG_HC1 + hc_num - 1).c_str());
|
snprintf_P(topic_t, sizeof(topic_t), "~/%s", Mqtt::tag_to_topic(EMSdevice::DeviceType::THERMOSTAT, DeviceValueTAG::TAG_HC1 + hc_num - 1).c_str());
|
||||||
|
|
||||||
doc["mode_stat_tpl"] = FJSON("{{value_json.hamode}}");
|
doc["mode_stat_tpl"] = FJSON("{{value_json.hamode}}");
|
||||||
doc["temp_stat_tpl"] = FJSON("{{value_json.seltemp}}");
|
doc["temp_stat_tpl"] = FJSON("{{value_json.seltemp}}");
|
||||||
@@ -447,12 +447,12 @@ void Thermostat::publish_ha_config_hc(uint8_t hc_num) {
|
|||||||
ids.add("ems-esp-thermostat");
|
ids.add("ems-esp-thermostat");
|
||||||
|
|
||||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("climate/%s/thermostat_hc%d/config"), Mqtt::base().c_str(), hc_num);
|
snprintf_P(topic, sizeof(topic), "climate/%s/thermostat_hc%d/config", Mqtt::base().c_str(), hc_num);
|
||||||
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
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
|
// enable the a special "thermostat_hc<n>" topic to take both mode strings and floats for each of the heating circuits
|
||||||
std::string topic2(Mqtt::MQTT_TOPIC_MAX_SIZE, '\0');
|
std::string topic2(Mqtt::MQTT_TOPIC_MAX_SIZE, '\0');
|
||||||
snprintf_P(&topic2[0], topic2.capacity() + 1, PSTR("thermostat_hc%d"), hc_num);
|
snprintf_P(&topic2[0], topic2.capacity() + 1, "thermostat_hc%d", hc_num);
|
||||||
register_mqtt_topic(topic2, [=](const char * m) { return thermostat_ha_cmd(m, hc_num); });
|
register_mqtt_topic(topic2, [=](const char * m) { return thermostat_ha_cmd(m, hc_num); });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1117,7 +1117,7 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
|
|||||||
char buf6[6];
|
char buf6[6];
|
||||||
snprintf_P(dateTime_,
|
snprintf_P(dateTime_,
|
||||||
sizeof(dateTime_),
|
sizeof(dateTime_),
|
||||||
PSTR("%s:%s:%s %s/%s/%s"),
|
"%s:%s:%s %s/%s/%s",
|
||||||
Helpers::smallitoa(buf1, telegram->message_data[2]), // hour
|
Helpers::smallitoa(buf1, telegram->message_data[2]), // hour
|
||||||
Helpers::smallitoa(buf2, telegram->message_data[4]), // minute
|
Helpers::smallitoa(buf2, telegram->message_data[4]), // minute
|
||||||
Helpers::smallitoa(buf3, telegram->message_data[5]), // second
|
Helpers::smallitoa(buf3, telegram->message_data[5]), // second
|
||||||
@@ -1143,7 +1143,7 @@ void Thermostat::process_RCError(std::shared_ptr<const Telegram> telegram) {
|
|||||||
buf[2] = telegram->message_data[2];
|
buf[2] = telegram->message_data[2];
|
||||||
buf[3] = 0;
|
buf[3] = 0;
|
||||||
has_update(telegram->read_value(errorNumber_, 3));
|
has_update(telegram->read_value(errorNumber_, 3));
|
||||||
snprintf_P(errorCode_, sizeof(errorCode_), PSTR("%s(%d)"), buf, errorNumber_);
|
snprintf_P(errorCode_, sizeof(errorCode_), "%s(%d)", buf, errorNumber_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x12 error log
|
// 0x12 error log
|
||||||
@@ -1165,7 +1165,7 @@ void Thermostat::process_RCErrorMessage(std::shared_ptr<const Telegram> telegram
|
|||||||
uint8_t day = telegram->message_data[7];
|
uint8_t day = telegram->message_data[7];
|
||||||
uint8_t hour = telegram->message_data[6];
|
uint8_t hour = telegram->message_data[6];
|
||||||
uint8_t min = telegram->message_data[8];
|
uint8_t min = telegram->message_data[8];
|
||||||
snprintf_P(lastCode_, sizeof(lastCode_), PSTR("%s(%d) %02d.%02d.%d %02d:%02d"), code, codeNo, day, month, year, hour, min);
|
snprintf_P(lastCode_, sizeof(lastCode_), "%s(%d) %02d.%02d.%d %02d:%02d", code, codeNo, day, month, year, hour, min);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2652,7 +2652,8 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
|
|||||||
register_device_value(tag, &hc->minflowtemp, DeviceValueType::UINT, nullptr, FL_(minflowtemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_minflowtemp));
|
register_device_value(tag, &hc->minflowtemp, DeviceValueType::UINT, nullptr, FL_(minflowtemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_minflowtemp));
|
||||||
register_device_value(tag, &hc->maxflowtemp, DeviceValueType::UINT, nullptr, FL_(maxflowtemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_maxflowtemp));
|
register_device_value(tag, &hc->maxflowtemp, DeviceValueType::UINT, nullptr, FL_(maxflowtemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_maxflowtemp));
|
||||||
register_device_value(tag, &hc->tempautotemp, DeviceValueType::UINT, FL_(div2), FL_(tempautotemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_tempautotemp));
|
register_device_value(tag, &hc->tempautotemp, DeviceValueType::UINT, FL_(div2), FL_(tempautotemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_tempautotemp));
|
||||||
register_device_value(tag, &hc->heatingtype, DeviceValueType::ENUM, FL_(enum_heatingtype), FL_(heatingtype), DeviceValueUOM::LIST, MAKE_CF_CB(set_heatingtype));
|
register_device_value(
|
||||||
|
tag, &hc->heatingtype, DeviceValueType::ENUM, FL_(enum_heatingtype), FL_(heatingtype), DeviceValueUOM::LIST, MAKE_CF_CB(set_heatingtype));
|
||||||
register_device_value(tag, &hc->summertemp, DeviceValueType::UINT, nullptr, FL_(summertemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_summertemp));
|
register_device_value(tag, &hc->summertemp, DeviceValueType::UINT, nullptr, FL_(summertemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_summertemp));
|
||||||
register_device_value(tag, &hc->summermode, DeviceValueType::BOOL, nullptr, FL_(summermode), DeviceValueUOM::BOOLEAN);
|
register_device_value(tag, &hc->summermode, DeviceValueType::BOOL, nullptr, FL_(summermode), DeviceValueUOM::BOOLEAN);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -304,16 +304,16 @@ std::string EMSdevice::to_string() const {
|
|||||||
|
|
||||||
// for devices that haven't been lookup yet, don't show all details
|
// for devices that haven't been lookup yet, don't show all details
|
||||||
if (product_id_ == 0) {
|
if (product_id_ == 0) {
|
||||||
snprintf_P(&str[0], str.capacity() + 1, PSTR("%s (DeviceID:0x%02X)"), name_.c_str(), device_id_);
|
snprintf_P(&str[0], str.capacity() + 1, "%s (DeviceID:0x%02X)", name_.c_str(), device_id_);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (brand_ == Brand::NO_BRAND) {
|
if (brand_ == Brand::NO_BRAND) {
|
||||||
snprintf_P(&str[0], str.capacity() + 1, PSTR("%s (DeviceID:0x%02X, ProductID:%d, Version:%s)"), name_.c_str(), device_id_, product_id_, version_.c_str());
|
snprintf_P(&str[0], str.capacity() + 1, "%s (DeviceID:0x%02X, ProductID:%d, Version:%s)", name_.c_str(), device_id_, product_id_, version_.c_str());
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(&str[0],
|
snprintf_P(&str[0],
|
||||||
str.capacity() + 1,
|
str.capacity() + 1,
|
||||||
PSTR("%s %s (DeviceID:0x%02X ProductID:%d, Version:%s)"),
|
"%s %s (DeviceID:0x%02X ProductID:%d, Version:%s)",
|
||||||
brand_to_string().c_str(),
|
brand_to_string().c_str(),
|
||||||
name_.c_str(),
|
name_.c_str(),
|
||||||
device_id_,
|
device_id_,
|
||||||
@@ -328,9 +328,9 @@ std::string EMSdevice::to_string() const {
|
|||||||
std::string EMSdevice::to_string_short() const {
|
std::string EMSdevice::to_string_short() const {
|
||||||
std::string str(160, '\0');
|
std::string str(160, '\0');
|
||||||
if (brand_ == Brand::NO_BRAND) {
|
if (brand_ == Brand::NO_BRAND) {
|
||||||
snprintf_P(&str[0], str.capacity() + 1, PSTR("%s: %s"), device_type_name().c_str(), name_.c_str());
|
snprintf_P(&str[0], str.capacity() + 1, "%s: %s", device_type_name().c_str(), name_.c_str());
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(&str[0], str.capacity() + 1, PSTR("%s: %s %s"), device_type_name().c_str(), brand_to_string().c_str(), name_.c_str());
|
snprintf_P(&str[0], str.capacity() + 1, "%s: %s %s", device_type_name().c_str(), brand_to_string().c_str(), name_.c_str());
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@@ -413,7 +413,7 @@ char * EMSdevice::show_telegram_handlers(char * result) {
|
|||||||
char str[10];
|
char str[10];
|
||||||
uint8_t i = 0;
|
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_);
|
snprintf_P(str, sizeof(str), "0x%02X", tf.telegram_type_id_);
|
||||||
strlcat(result, str, 200);
|
strlcat(result, str, 200);
|
||||||
if (++i < size) {
|
if (++i < size) {
|
||||||
strlcat(result, " ", 200);
|
strlcat(result, " ", 200);
|
||||||
@@ -961,7 +961,7 @@ bool EMSdevice::generate_values_json(JsonObject & root, const uint8_t tag_filter
|
|||||||
time_value = (divider) ? time_value / divider : time_value; // sometimes we need to divide by 60
|
time_value = (divider) ? time_value / divider : time_value; // sometimes we need to divide by 60
|
||||||
if (console) {
|
if (console) {
|
||||||
char time_s[40];
|
char time_s[40];
|
||||||
snprintf_P(time_s, sizeof(time_s), PSTR("%d days %d hours %d minutes"), (time_value / 1440), ((time_value % 1440) / 60), (time_value % 60));
|
snprintf_P(time_s, sizeof(time_s), "%d days %d hours %d minutes", (time_value / 1440), ((time_value % 1440) / 60), (time_value % 60));
|
||||||
json[name] = time_s;
|
json[name] = time_s;
|
||||||
} else {
|
} else {
|
||||||
json[name] = time_value;
|
json[name] = time_value;
|
||||||
|
|||||||
@@ -520,7 +520,7 @@ void EMSESP::publish_device_values(uint8_t device_type) {
|
|||||||
// publish it under a single topic, only if we have data to publish
|
// publish it under a single topic, only if we have data to publish
|
||||||
if (need_publish) {
|
if (need_publish) {
|
||||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
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());
|
snprintf_P(topic, sizeof(topic), "%s_data", EMSdevice::device_type_2_device_name(device_type).c_str());
|
||||||
Mqtt::publish(topic, json);
|
Mqtt::publish(topic, json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -580,7 +580,7 @@ bool EMSESP::get_device_value_info(JsonObject & root, const char * cmd, const in
|
|||||||
uint8_t i = 1;
|
uint8_t i = 1;
|
||||||
for (const auto & sensor : EMSESP::sensor_devices()) {
|
for (const auto & sensor : EMSESP::sensor_devices()) {
|
||||||
char sensorID[10];
|
char sensorID[10];
|
||||||
snprintf_P(sensorID, 10, PSTR("sensor%d"), i++);
|
snprintf_P(sensorID, 10, "sensor%d", i++);
|
||||||
if ((strcmp(cmd, sensorID) == 0) || (strcmp(cmd, Helpers::toLower(sensor.to_string()).c_str()) == 0)) {
|
if ((strcmp(cmd, sensorID) == 0) || (strcmp(cmd, Helpers::toLower(sensor.to_string()).c_str()) == 0)) {
|
||||||
root["name"] = sensor.to_string();
|
root["name"] = sensor.to_string();
|
||||||
if (Helpers::hasValue(sensor.temperature_c)) {
|
if (Helpers::hasValue(sensor.temperature_c)) {
|
||||||
@@ -669,7 +669,7 @@ std::string EMSESP::pretty_telegram(std::shared_ptr<const Telegram> telegram) {
|
|||||||
if (offset) {
|
if (offset) {
|
||||||
snprintf_P(&str[0],
|
snprintf_P(&str[0],
|
||||||
str.capacity() + 1,
|
str.capacity() + 1,
|
||||||
PSTR("%s(0x%02X) %s %s(0x%02X), %s(0x%02X), data: %s (offset %d)"),
|
"%s(0x%02X) %s %s(0x%02X), %s(0x%02X), data: %s (offset %d)",
|
||||||
src_name.c_str(),
|
src_name.c_str(),
|
||||||
src,
|
src,
|
||||||
direction.c_str(),
|
direction.c_str(),
|
||||||
@@ -682,7 +682,7 @@ std::string EMSESP::pretty_telegram(std::shared_ptr<const Telegram> telegram) {
|
|||||||
} else {
|
} else {
|
||||||
snprintf_P(&str[0],
|
snprintf_P(&str[0],
|
||||||
str.capacity() + 1,
|
str.capacity() + 1,
|
||||||
PSTR("%s(0x%02X) %s %s(0x%02X), %s(0x%02X), data: %s"),
|
"%s(0x%02X) %s %s(0x%02X), %s(0x%02X), data: %s",
|
||||||
src_name.c_str(),
|
src_name.c_str(),
|
||||||
src,
|
src,
|
||||||
direction.c_str(),
|
direction.c_str(),
|
||||||
@@ -759,7 +759,7 @@ void EMSESP::process_version(std::shared_ptr<const Telegram> telegram) {
|
|||||||
|
|
||||||
// get version as XX.XX
|
// get version as XX.XX
|
||||||
std::string version(6, '\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]);
|
snprintf_P(&version[0], version.capacity() + 1, "%02d.%02d", telegram->message_data[offset + 1], telegram->message_data[offset + 2]);
|
||||||
|
|
||||||
// some devices store the protocol type (HT3, Buderus) in the last byte
|
// some devices store the protocol type (HT3, Buderus) in the last byte
|
||||||
uint8_t brand;
|
uint8_t brand;
|
||||||
|
|||||||
32
src/mqtt.cpp
32
src/mqtt.cpp
@@ -265,9 +265,9 @@ void Mqtt::show_mqtt(uuid::console::Shell & shell) {
|
|||||||
auto content = message.content_;
|
auto content = message.content_;
|
||||||
char topic[MQTT_TOPIC_MAX_SIZE];
|
char topic[MQTT_TOPIC_MAX_SIZE];
|
||||||
if ((strncmp(content->topic.c_str(), "homeassistant/", 13) != 0)) {
|
if ((strncmp(content->topic.c_str(), "homeassistant/", 13) != 0)) {
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("%s/%s"), Mqtt::base().c_str(), content->topic.c_str());
|
snprintf_P(topic, sizeof(topic), "%s/%s", Mqtt::base().c_str(), content->topic.c_str());
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("%s"), content->topic.c_str());
|
snprintf_P(topic, sizeof(topic), "%s", content->topic.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content->operation == Operation::PUBLISH) {
|
if (content->operation == Operation::PUBLISH) {
|
||||||
@@ -553,7 +553,7 @@ void Mqtt::start() {
|
|||||||
|
|
||||||
// create will_topic with the base prefixed. It has to be static because asyncmqttclient destroys the reference
|
// create will_topic with the base prefixed. It has to be static because asyncmqttclient destroys the reference
|
||||||
static char will_topic[MQTT_TOPIC_MAX_SIZE];
|
static char will_topic[MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(will_topic, MQTT_TOPIC_MAX_SIZE, PSTR("%s/status"), mqtt_base_.c_str());
|
snprintf_P(will_topic, MQTT_TOPIC_MAX_SIZE, "%s/status", mqtt_base_.c_str());
|
||||||
mqttClient_->setWill(will_topic, 1, true, "offline"); // with qos 1, retain true
|
mqttClient_->setWill(will_topic, 1, true, "offline"); // with qos 1, retain true
|
||||||
|
|
||||||
mqttClient_->onMessage([this](char * topic, char * payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) {
|
mqttClient_->onMessage([this](char * topic, char * payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) {
|
||||||
@@ -707,7 +707,7 @@ void Mqtt::ha_status() {
|
|||||||
ids.add("ems-esp");
|
ids.add("ems-esp");
|
||||||
|
|
||||||
char topic[MQTT_TOPIC_MAX_SIZE];
|
char topic[MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("sensor/%s/system/config"), mqtt_base_.c_str());
|
snprintf_P(topic, sizeof(topic), "sensor/%s/system/config", mqtt_base_.c_str());
|
||||||
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
||||||
|
|
||||||
// create the sensors - must match the MQTT payload keys
|
// create the sensors - must match the MQTT payload keys
|
||||||
@@ -868,7 +868,7 @@ void Mqtt::process_queue() {
|
|||||||
// leave topic as it is
|
// leave topic as it is
|
||||||
strcpy(topic, message->topic.c_str());
|
strcpy(topic, message->topic.c_str());
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(topic, MQTT_TOPIC_MAX_SIZE, PSTR("%s/%s"), mqtt_base_.c_str(), message->topic.c_str());
|
snprintf_P(topic, MQTT_TOPIC_MAX_SIZE, "%s/%s", mqtt_base_.c_str(), message->topic.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we're subscribing...
|
// if we're subscribing...
|
||||||
@@ -966,29 +966,29 @@ void Mqtt::publish_mqtt_ha_sensor(uint8_t type, // EMSdevice
|
|||||||
// create entity by add the tag if present, seperating with a .
|
// create entity by add the tag if present, seperating with a .
|
||||||
char new_entity[50];
|
char new_entity[50];
|
||||||
if (have_tag) {
|
if (have_tag) {
|
||||||
snprintf_P(new_entity, sizeof(new_entity), PSTR("%s.%s"), EMSdevice::tag_to_string(tag).c_str(), uuid::read_flash_string(entity).c_str());
|
snprintf_P(new_entity, sizeof(new_entity), "%s.%s", EMSdevice::tag_to_string(tag).c_str(), uuid::read_flash_string(entity).c_str());
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(new_entity, sizeof(new_entity), PSTR("%s"), uuid::read_flash_string(entity).c_str());
|
snprintf_P(new_entity, sizeof(new_entity), "%s", uuid::read_flash_string(entity).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// build unique identifier which will be used in the topic
|
// build unique identifier which will be used in the topic
|
||||||
// and replacing all . with _ as not to break HA
|
// and replacing all . with _ as not to break HA
|
||||||
std::string uniq(50, '\0');
|
std::string uniq(50, '\0');
|
||||||
snprintf_P(&uniq[0], uniq.capacity() + 1, PSTR("%s_%s"), device_name, new_entity);
|
snprintf_P(&uniq[0], uniq.capacity() + 1, "%s_%s", device_name, new_entity);
|
||||||
std::replace(uniq.begin(), uniq.end(), '.', '_');
|
std::replace(uniq.begin(), uniq.end(), '.', '_');
|
||||||
doc["uniq_id"] = uniq;
|
doc["uniq_id"] = uniq;
|
||||||
|
|
||||||
// state topic
|
// state topic
|
||||||
char stat_t[MQTT_TOPIC_MAX_SIZE];
|
char stat_t[MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(stat_t, sizeof(stat_t), PSTR("~/%s"), tag_to_topic(device_type, tag).c_str());
|
snprintf_P(stat_t, sizeof(stat_t), "~/%s", tag_to_topic(device_type, tag).c_str());
|
||||||
doc["stat_t"] = stat_t;
|
doc["stat_t"] = stat_t;
|
||||||
|
|
||||||
// name = <device> <tag> <name>
|
// name = <device> <tag> <name>
|
||||||
char new_name[80];
|
char new_name[80];
|
||||||
if (have_tag) {
|
if (have_tag) {
|
||||||
snprintf_P(new_name, sizeof(new_name), PSTR("%s %s %s"), device_name, EMSdevice::tag_to_string(tag).c_str(), uuid::read_flash_string(name).c_str());
|
snprintf_P(new_name, sizeof(new_name), "%s %s %s", device_name, EMSdevice::tag_to_string(tag).c_str(), uuid::read_flash_string(name).c_str());
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(new_name, sizeof(new_name), PSTR("%s %s"), device_name, uuid::read_flash_string(name).c_str());
|
snprintf_P(new_name, sizeof(new_name), "%s %s", device_name, uuid::read_flash_string(name).c_str());
|
||||||
}
|
}
|
||||||
new_name[0] = toupper(new_name[0]); // capitalize first letter
|
new_name[0] = toupper(new_name[0]); // capitalize first letter
|
||||||
doc["name"] = new_name;
|
doc["name"] = new_name;
|
||||||
@@ -997,9 +997,9 @@ void Mqtt::publish_mqtt_ha_sensor(uint8_t type, // EMSdevice
|
|||||||
// if its nested mqtt format then use the appended entity name, otherwise take the original
|
// if its nested mqtt format then use the appended entity name, otherwise take the original
|
||||||
char val_tpl[50];
|
char val_tpl[50];
|
||||||
if (is_nested) {
|
if (is_nested) {
|
||||||
snprintf_P(val_tpl, sizeof(val_tpl), PSTR("{{value_json.%s}}"), new_entity);
|
snprintf_P(val_tpl, sizeof(val_tpl), "{{value_json.%s}}", new_entity);
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(val_tpl, sizeof(val_tpl), PSTR("{{value_json.%s}}"), uuid::read_flash_string(entity).c_str());
|
snprintf_P(val_tpl, sizeof(val_tpl), "{{value_json.%s}}", uuid::read_flash_string(entity).c_str());
|
||||||
}
|
}
|
||||||
doc["val_tpl"] = val_tpl;
|
doc["val_tpl"] = val_tpl;
|
||||||
|
|
||||||
@@ -1008,7 +1008,7 @@ void Mqtt::publish_mqtt_ha_sensor(uint8_t type, // EMSdevice
|
|||||||
// look at the device value type
|
// look at the device value type
|
||||||
if (type == DeviceValueType::BOOL) {
|
if (type == DeviceValueType::BOOL) {
|
||||||
// binary sensor
|
// binary sensor
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("binary_sensor/%s/%s/config"), mqtt_base_.c_str(), uniq.c_str()); // topic
|
snprintf_P(topic, sizeof(topic), "binary_sensor/%s/%s/config", mqtt_base_.c_str(), uniq.c_str()); // topic
|
||||||
|
|
||||||
// how to render boolean. HA only accepts String values
|
// how to render boolean. HA only accepts String values
|
||||||
char result[10];
|
char result[10];
|
||||||
@@ -1016,7 +1016,7 @@ void Mqtt::publish_mqtt_ha_sensor(uint8_t type, // EMSdevice
|
|||||||
doc[F("payload_off")] = Helpers::render_boolean(result, false);
|
doc[F("payload_off")] = Helpers::render_boolean(result, false);
|
||||||
} else {
|
} else {
|
||||||
// normal HA sensor, not a boolean one
|
// normal HA sensor, not a boolean one
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("sensor/%s/%s/config"), mqtt_base_.c_str(), uniq.c_str()); // topic
|
snprintf_P(topic, sizeof(topic), "sensor/%s/%s/config", mqtt_base_.c_str(), uniq.c_str()); // topic
|
||||||
|
|
||||||
bool set_state_class = false;
|
bool set_state_class = false;
|
||||||
|
|
||||||
@@ -1089,7 +1089,7 @@ void Mqtt::publish_mqtt_ha_sensor(uint8_t type, // EMSdevice
|
|||||||
ids.add("ems-esp");
|
ids.add("ems-esp");
|
||||||
} else {
|
} else {
|
||||||
char ha_device[40];
|
char ha_device[40];
|
||||||
snprintf_P(ha_device, sizeof(ha_device), PSTR("ems-esp-%s"), device_name);
|
snprintf_P(ha_device, sizeof(ha_device), "ems-esp-%s", device_name);
|
||||||
ids.add(ha_device);
|
ids.add(ha_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ void Shower::send_mqtt_stat(bool state, bool force) {
|
|||||||
ids.add("ems-esp");
|
ids.add("ems-esp");
|
||||||
|
|
||||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("binary_sensor/%s/shower_active/config"), Mqtt::base().c_str());
|
snprintf_P(topic, sizeof(topic), "binary_sensor/%s/shower_active/config", Mqtt::base().c_str());
|
||||||
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ void Shower::publish_values() {
|
|||||||
// only publish shower duration if there is a value
|
// only publish shower duration if there is a value
|
||||||
if (duration_ > SHOWER_MIN_DURATION) {
|
if (duration_ > SHOWER_MIN_DURATION) {
|
||||||
char s[50];
|
char s[50];
|
||||||
snprintf_P(s, 50, PSTR("%d minutes and %d seconds"), (uint8_t)(duration_ / 60000), (uint8_t)((duration_ / 1000) % 60));
|
snprintf_P(s, 50, "%d minutes and %d seconds", (uint8_t)(duration_ / 60000), (uint8_t)((duration_ / 1000) % 60));
|
||||||
doc["duration"] = s;
|
doc["duration"] = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -797,8 +797,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
|
|||||||
|
|
||||||
// fit it up, to its limit of the Json buffer (which is about 169 records)
|
// fit it up, to its limit of the Json buffer (which is about 169 records)
|
||||||
for (uint8_t i = 0; i < 200; i++) {
|
for (uint8_t i = 0; i < 200; i++) {
|
||||||
snprintf_P(key, 7, PSTR("key%03d"), i);
|
snprintf_P(key, 7, "key%03d", i);
|
||||||
snprintf_P(value, 7, PSTR("val%03d"), i);
|
snprintf_P(value, 7, "val%03d", i);
|
||||||
doc[key] = value;
|
doc[key] = value;
|
||||||
}
|
}
|
||||||
doc.shrinkToFit();
|
doc.shrinkToFit();
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.2.2b4"
|
#define EMSESP_APP_VERSION "3.2.2b5"
|
||||||
|
|||||||
@@ -69,11 +69,11 @@ void WebSettings::read(WebSettings & settings, JsonObject & root) {
|
|||||||
|
|
||||||
for (uint8_t i = 0; i < NUM_SENSOR_NAMES; i++) {
|
for (uint8_t i = 0; i < NUM_SENSOR_NAMES; i++) {
|
||||||
char buf[20];
|
char buf[20];
|
||||||
snprintf_P(buf, sizeof(buf), PSTR("sensor_id%d"), i);
|
snprintf_P(buf, sizeof(buf), "sensor_id%d", i);
|
||||||
root[buf] = settings.sensor[i].id;
|
root[buf] = settings.sensor[i].id;
|
||||||
snprintf_P(buf, sizeof(buf), PSTR("sensor_name%d"), i);
|
snprintf_P(buf, sizeof(buf), "sensor_name%d", i);
|
||||||
root[buf] = settings.sensor[i].name;
|
root[buf] = settings.sensor[i].name;
|
||||||
snprintf_P(buf, sizeof(buf), PSTR("sensor_offset%d"), i);
|
snprintf_P(buf, sizeof(buf), "sensor_offset%d", i);
|
||||||
root[buf] = settings.sensor[i].offset;
|
root[buf] = settings.sensor[i].offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,11 +207,11 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings)
|
|||||||
|
|
||||||
for (uint8_t i = 0; i < NUM_SENSOR_NAMES; i++) {
|
for (uint8_t i = 0; i < NUM_SENSOR_NAMES; i++) {
|
||||||
char buf[20];
|
char buf[20];
|
||||||
snprintf_P(buf, sizeof(buf), PSTR("sensor_id%d"), i);
|
snprintf_P(buf, sizeof(buf), "sensor_id%d", i);
|
||||||
settings.sensor[i].id = root[buf] | EMSESP_DEFAULT_SENSOR_NAME;
|
settings.sensor[i].id = root[buf] | EMSESP_DEFAULT_SENSOR_NAME;
|
||||||
snprintf_P(buf, sizeof(buf), PSTR("sensor_name%d"), i);
|
snprintf_P(buf, sizeof(buf), "sensor_name%d", i);
|
||||||
settings.sensor[i].name = root[buf] | EMSESP_DEFAULT_SENSOR_NAME;
|
settings.sensor[i].name = root[buf] | EMSESP_DEFAULT_SENSOR_NAME;
|
||||||
snprintf_P(buf, sizeof(buf), PSTR("sensor_offset%d"), i);
|
snprintf_P(buf, sizeof(buf), "sensor_offset%d", i);
|
||||||
settings.sensor[i].offset = root[buf] | 0;
|
settings.sensor[i].offset = root[buf] | 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user