mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
testing MQTT hc
This commit is contained in:
@@ -24,7 +24,7 @@ class DummySettings {
|
||||
bool shower_alert = false;
|
||||
bool hide_led = false;
|
||||
uint16_t publish_time = 10; // seconds
|
||||
uint8_t mqtt_format = 1; // 1=single, 2=nested, 3=ha, 4=custom
|
||||
uint8_t mqtt_format = 3; // 1=single, 2=nested, 3=ha, 4=custom
|
||||
uint8_t mqtt_qos = 0;
|
||||
String hostname = "ems-esp";
|
||||
String jwtSecret = "ems-esp";
|
||||
|
||||
@@ -270,7 +270,6 @@ void Thermostat::publish_values() {
|
||||
}
|
||||
|
||||
uint8_t flags = this->model();
|
||||
bool has_data = false;
|
||||
|
||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_MEDIUM> doc;
|
||||
JsonObject rootThermostat = doc.to<JsonObject>();
|
||||
@@ -324,12 +323,11 @@ void Thermostat::publish_values() {
|
||||
}
|
||||
|
||||
// go through all the heating circuits
|
||||
bool has_data = false;
|
||||
for (const auto & hc : heating_circuits_) {
|
||||
if (!Helpers::hasValue(hc->setpoint_roomTemp)) {
|
||||
break; // skip this HC
|
||||
}
|
||||
|
||||
if (hc->is_active()) {
|
||||
has_data = true;
|
||||
|
||||
// if the MQTT format is 'nested' or 'ha' then create the parent object hc<n>
|
||||
// if (mqtt_format_ != MQTT_format::SINGLE) {
|
||||
if ((mqtt_format_ == MQTT_format::NESTED) || (mqtt_format_ == MQTT_format::HA)) {
|
||||
@@ -445,6 +443,7 @@ void Thermostat::publish_values() {
|
||||
// see if we have already registered this with HA MQTT Discovery, if not send the config
|
||||
if (!hc->ha_registered()) {
|
||||
register_mqtt_ha_config(hc->hc_num());
|
||||
hc->ha_registered(true);
|
||||
}
|
||||
// send the thermostat topic and payload data
|
||||
std::string topic(100, '\0');
|
||||
@@ -452,13 +451,13 @@ void Thermostat::publish_values() {
|
||||
Mqtt::publish(topic, doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_data) {
|
||||
return; // nothing to send, quit
|
||||
}
|
||||
|
||||
// if we're using nested json, send all in one go under one topic called thermostat_data
|
||||
// if ((mqtt_format_ == MQTT_format::NESTED) || (mqtt_format_ == MQTT_format::CUSTOM)) {
|
||||
if (mqtt_format_ == MQTT_format::NESTED) {
|
||||
Mqtt::publish("thermostat_data", doc);
|
||||
}
|
||||
@@ -824,9 +823,10 @@ void Thermostat::show_values(uuid::console::Shell & shell) {
|
||||
}
|
||||
|
||||
for (const auto & hc : heating_circuits_) {
|
||||
if (!Helpers::hasValue(hc->setpoint_roomTemp)) {
|
||||
if (!hc->is_active()) {
|
||||
break; // skip this HC
|
||||
}
|
||||
|
||||
shell.printfln(F(" Heating Circuit %d:"), hc->hc_num());
|
||||
|
||||
// different thermostat types store their temperature values differently
|
||||
|
||||
@@ -70,6 +70,15 @@ class Thermostat : public EMSdevice {
|
||||
return ha_registered_;
|
||||
}
|
||||
|
||||
void ha_registered(bool b) {
|
||||
ha_registered_ = b;
|
||||
}
|
||||
|
||||
// determines if the heating circuit is actually present and has data
|
||||
bool is_active() {
|
||||
return Helpers::hasValue(setpoint_roomTemp);
|
||||
}
|
||||
|
||||
uint8_t get_mode(uint8_t flags) const;
|
||||
uint8_t get_mode_type(uint8_t flags) const;
|
||||
|
||||
@@ -275,7 +284,7 @@ class Thermostat : public EMSdevice {
|
||||
void set_display(const char * value, const int8_t id);
|
||||
void set_building(const char * value, const int8_t id);
|
||||
void set_language(const char * value, const int8_t id);
|
||||
};
|
||||
}; // namespace emsesp
|
||||
|
||||
} // namespace emsesp
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace emsesp {
|
||||
// used with the 'test' command, under su/admin
|
||||
void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
||||
if (command == "default") {
|
||||
run_test(shell, "mqtt"); // add the default test case here
|
||||
run_test(shell, "thermostat"); // add the default test case here
|
||||
}
|
||||
|
||||
if (command.empty()) {
|
||||
@@ -223,11 +223,18 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
||||
// EMSESP::add_device(0x08, 123, version, EMSdevice::Brand::BUDERUS); // Nefit Trendline
|
||||
|
||||
// add a thermostat
|
||||
EMSESP::add_device(0x18, 157, version, EMSdevice::Brand::BOSCH); // Bosch CR100 - https://github.com/proddy/EMS-ESP/issues/355
|
||||
EMSESP::add_device(0x10, 192, version, EMSdevice::Brand::JUNKERS); // FW120
|
||||
|
||||
// RCPLUSStatusMessage_HC1(0x01A5)
|
||||
uart_telegram({0x98, 0x00, 0xFF, 0x00, 0x01, 0xA5, 0x00, 0xCF, 0x21, 0x2E, 0x00, 0x00, 0x2E, 0x24,
|
||||
// HC1
|
||||
uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x6F, 0x00, 0xCF, 0x21, 0x2E, 0x20, 0x00, 0x2E, 0x24,
|
||||
0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03});
|
||||
|
||||
// HC2
|
||||
uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x70, 0x00, 0xCF, 0x22, 0x2F, 0x10, 0x00, 0x2E, 0x24,
|
||||
0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03});
|
||||
|
||||
// HC3
|
||||
uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
|
||||
}
|
||||
|
||||
if (command == "tc100") {
|
||||
@@ -393,7 +400,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
||||
0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03});
|
||||
|
||||
uart_telegram("98 00 FF 00 01 A5 00 CF 21 2E 00 00 2E 24 03 25 03 03 01 03 25 00 C8 00 00 11 01 03"); // without CRC
|
||||
uart_telegram_withCRC("98 00 FF 00 01 A5 00 CF 21 2E 00 00 2E 24 03 25 03 03 01 03 25 00 C8 00 00 11 01 03 13"); // with CRC
|
||||
uart_telegram_withCRC("98 00 FF 00 01 A6 00 CF 21 2E 00 00 2E 24 03 25 03 03 01 03 25 00 C8 00 00 11 01 03 6B"); // with CRC
|
||||
|
||||
EMSESP::txservice_.flush_tx_queue();
|
||||
shell.loop_all();
|
||||
|
||||
Reference in New Issue
Block a user