mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
added test command (console&web), to simulate adding devices. still experimental
This commit is contained in:
2
makefile
2
makefile
@@ -26,7 +26,7 @@ CXX_STANDARD := -std=c++11
|
|||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
# Defined Symbols
|
# Defined Symbols
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
DEFINES += -DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DEMSESP_DEBUG -DEMSESP_STANDALONE
|
DEFINES += -DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DEMSESP_DEBUG -DEMSESP_STANDALONE -DEMSESP_TEST
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
# Sources & Files
|
# Sources & Files
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ extra_configs =
|
|||||||
debug_flags =
|
debug_flags =
|
||||||
; -D EMSESP_DEBUG
|
; -D EMSESP_DEBUG
|
||||||
; -D EMSESP_UART_DEBUG
|
; -D EMSESP_UART_DEBUG
|
||||||
|
; -D EMSESP_TEST
|
||||||
; -D EMSESP_FORCE_SERIAL
|
; -D EMSESP_FORCE_SERIAL
|
||||||
; -D ENABLE_CORS
|
; -D ENABLE_CORS
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,9 @@
|
|||||||
#include "emsesp.h"
|
#include "emsesp.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
#if defined(EMSESP_TEST)
|
||||||
#include "test/test.h"
|
#include "test/test.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace emsesp {
|
namespace emsesp {
|
||||||
|
|
||||||
@@ -426,11 +428,7 @@ void EMSESPShell::add_console_commands() {
|
|||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
// System context menu
|
||||||
* add all the submenu contexts...
|
|
||||||
*/
|
|
||||||
|
|
||||||
// System
|
|
||||||
commands->add_command(ShellContext::MAIN,
|
commands->add_command(ShellContext::MAIN,
|
||||||
CommandFlags::USER,
|
CommandFlags::USER,
|
||||||
flash_string_vector{F_(system)},
|
flash_string_vector{F_(system)},
|
||||||
@@ -471,26 +469,22 @@ void Console::enter_custom_context(Shell & shell, unsigned int context) {
|
|||||||
|
|
||||||
// each custom context has the common commands like log, help, exit, su etc
|
// each custom context has the common commands like log, help, exit, su etc
|
||||||
void Console::load_standard_commands(unsigned int context) {
|
void Console::load_standard_commands(unsigned int context) {
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_TEST)
|
||||||
EMSESPShell::commands->add_command(context,
|
EMSESPShell::commands->add_command(context,
|
||||||
CommandFlags::USER,
|
CommandFlags::USER,
|
||||||
flash_string_vector{F("test")},
|
flash_string_vector{F_(test)},
|
||||||
flash_string_vector{F_(name_optional)},
|
flash_string_vector{F_(name_optional)},
|
||||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||||
if (arguments.size() == 0) {
|
if (arguments.size() == 0) {
|
||||||
Test::run_test(shell, "default");
|
Test::run_test_shell(shell, "default");
|
||||||
} else {
|
} else {
|
||||||
Test::run_test(shell, arguments.front());
|
Test::run_test_shell(shell, arguments.front());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
EMSESPShell::commands->add_command(context,
|
|
||||||
CommandFlags::USER,
|
|
||||||
flash_string_vector{F("t")},
|
|
||||||
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
|
|
||||||
Test::run_test(shell, "default");
|
|
||||||
});
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EMSESPShell::commands->add_command(
|
EMSESPShell::commands->add_command(
|
||||||
context,
|
context,
|
||||||
CommandFlags::USER,
|
CommandFlags::USER,
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ MAKE_PSTR_WORD(command)
|
|||||||
MAKE_PSTR_WORD(commands)
|
MAKE_PSTR_WORD(commands)
|
||||||
MAKE_PSTR_WORD(info)
|
MAKE_PSTR_WORD(info)
|
||||||
MAKE_PSTR_WORD(report)
|
MAKE_PSTR_WORD(report)
|
||||||
|
MAKE_PSTR_WORD(test)
|
||||||
|
|
||||||
// devices
|
// devices
|
||||||
MAKE_PSTR_WORD(boiler)
|
MAKE_PSTR_WORD(boiler)
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
|
|
||||||
#include "version.h" // firmware version of EMS-ESP
|
#include "version.h" // firmware version of EMS-ESP
|
||||||
|
|
||||||
|
#if defined(EMSESP_TEST)
|
||||||
|
#include "test/test.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace emsesp {
|
namespace emsesp {
|
||||||
|
|
||||||
uuid::log::Logger System::logger_{F_(system), uuid::log::Facility::KERN};
|
uuid::log::Logger System::logger_{F_(system), uuid::log::Facility::KERN};
|
||||||
@@ -47,7 +51,12 @@ String System::syslog_host_;
|
|||||||
|
|
||||||
// send on/off to a gpio pin
|
// send on/off to a gpio pin
|
||||||
// value: true = HIGH, false = LOW
|
// value: true = HIGH, false = LOW
|
||||||
|
// http://ems-esp/api?device=system&cmd=pin&data=1&id=2
|
||||||
bool System::command_pin(const char * value, const int8_t id) {
|
bool System::command_pin(const char * value, const int8_t id) {
|
||||||
|
if (id < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool v = false;
|
bool v = false;
|
||||||
if (Helpers::value2bool(value, v)) {
|
if (Helpers::value2bool(value, v)) {
|
||||||
pinMode(id, OUTPUT);
|
pinMode(id, OUTPUT);
|
||||||
@@ -191,6 +200,10 @@ void System::start() {
|
|||||||
Command::add(EMSdevice::DeviceType::SYSTEM, settings.ems_bus_id, F_(fetch), System::command_fetch);
|
Command::add(EMSdevice::DeviceType::SYSTEM, settings.ems_bus_id, F_(fetch), System::command_fetch);
|
||||||
Command::add_with_json(EMSdevice::DeviceType::SYSTEM, F_(info), System::command_info);
|
Command::add_with_json(EMSdevice::DeviceType::SYSTEM, F_(info), System::command_info);
|
||||||
Command::add_with_json(EMSdevice::DeviceType::SYSTEM, F_(report), System::command_report);
|
Command::add_with_json(EMSdevice::DeviceType::SYSTEM, F_(report), System::command_report);
|
||||||
|
|
||||||
|
#if defined(EMSESP_TEST)
|
||||||
|
Command::add(EMSdevice::DeviceType::SYSTEM, settings.ems_bus_id, F_(test), System::command_test);
|
||||||
|
#endif
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -274,7 +287,6 @@ void System::loop() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::show_mem(const char * note) {
|
void System::show_mem(const char * note) {
|
||||||
@@ -1073,4 +1085,13 @@ bool System::command_report(const char * value, const int8_t id, JsonObject & js
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(EMSESP_TEST)
|
||||||
|
// run a test
|
||||||
|
// e.g. http://ems-esp/api?device=system&cmd=test&data=boiler
|
||||||
|
bool System::command_test(const char * value, const int8_t id) {
|
||||||
|
Test::run_test(value, id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ class System {
|
|||||||
static bool command_info(const char * value, const int8_t id, JsonObject & json);
|
static bool command_info(const char * value, const int8_t id, JsonObject & json);
|
||||||
static bool command_report(const char * value, const int8_t id, JsonObject & json);
|
static bool command_report(const char * value, const int8_t id, JsonObject & json);
|
||||||
|
|
||||||
|
#if defined(EMSESP_TEST)
|
||||||
|
static bool command_test(const char * value, const int8_t id);
|
||||||
|
#endif
|
||||||
|
|
||||||
static uint8_t free_mem();
|
static uint8_t free_mem();
|
||||||
static void upload_status(bool in_progress);
|
static void upload_status(bool in_progress);
|
||||||
static bool upload_status();
|
static bool upload_status();
|
||||||
|
|||||||
@@ -17,24 +17,140 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_TEST)
|
||||||
|
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
|
// create some fake test data
|
||||||
|
|
||||||
namespace emsesp {
|
namespace emsesp {
|
||||||
|
|
||||||
// create some fake test data
|
// no shell
|
||||||
|
void Test::run_test(const char * command, int8_t id) {
|
||||||
|
if ((command == nullptr) || (strlen(command) == 0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(command, "general") == 0) {
|
||||||
|
EMSESP::logger().info(F("Testing general..."));
|
||||||
|
|
||||||
|
add_device(0x08, 123); // Nefit Trendline
|
||||||
|
add_device(0x18, 157); // Bosch CR100
|
||||||
|
|
||||||
|
// add some data
|
||||||
|
// Boiler -> Me, UBAMonitorFast(0x18), telegram: 08 00 18 00 00 02 5A 73 3D 0A 10 65 40 02 1A 80 00 01 E1 01 76 0E 3D 48 00 C9 44 02 00 (#data=25)
|
||||||
|
uart_telegram({0x08, 0x00, 0x18, 0x00, 0x00, 0x02, 0x5A, 0x73, 0x3D, 0x0A, 0x10, 0x65, 0x40, 0x02, 0x1A,
|
||||||
|
0x80, 0x00, 0x01, 0xE1, 0x01, 0x76, 0x0E, 0x3D, 0x48, 0x00, 0xC9, 0x44, 0x02, 0x00});
|
||||||
|
|
||||||
|
// Boiler -> Thermostat, UBAParameterWW(0x33), telegram: 08 97 33 00 23 24 (#data=2)
|
||||||
|
uart_telegram({0x08, 0x98, 0x33, 0x00, 0x23, 0x24});
|
||||||
|
|
||||||
|
// Boiler -> Me, UBAParameterWW(0x33), telegram: 08 0B 33 00 08 FF 34 FB 00 28 00 00 46 00 FF FF 00 (#data=13)
|
||||||
|
uart_telegram({0x08, 0x0B, 0x33, 0x00, 0x08, 0xFF, 0x34, 0xFB, 0x00, 0x28, 0x00, 0x00, 0x46, 0x00, 0xFF, 0xFF, 0x00});
|
||||||
|
|
||||||
|
// Thermostat RCPLUSStatusMessage_HC1(0x01A5)
|
||||||
|
uart_telegram({0x98, 0x00, 0xFF, 0x00, 0x01, 0xA5, 0x00, 0xCF, 0x21, 0x2E, 0x00, 0x00, 0x2E, 0x24,
|
||||||
|
0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(command, "gateway") == 0) {
|
||||||
|
EMSESP::logger().info(F("Testing gateway..."));
|
||||||
|
|
||||||
|
// add 0x48 KM200, via a version command
|
||||||
|
rx_telegram({0x48, 0x0B, 0x02, 0x00, 0xBD, 0x04, 0x06, 00, 00, 00, 00, 00, 00, 00});
|
||||||
|
|
||||||
|
// Boiler(0x08) -> All(0x00), UBADevices(0x07), data: 09 01 00 00 00 00 00 00 01 00 00 00 00
|
||||||
|
// check: make sure 0x48 is not detected again !
|
||||||
|
rx_telegram({0x08, 0x00, 0x07, 0x00, 0x09, 01, 00, 00, 00, 00, 00, 00, 01, 00, 00, 00, 00});
|
||||||
|
|
||||||
|
// add thermostat - Thermostat: RC300/RC310/Moduline 3000/CW400/Sense II (DeviceID:0x10, ProductID:158, Version:03.03) ** master device **
|
||||||
|
add_device(0x10, 158); // Nefit Trendline
|
||||||
|
|
||||||
|
// simulate incoming telegram
|
||||||
|
// Thermostat(0x10) -> 48(0x48), ?(0x26B), data: 6B 08 4F 00 00 00 02 00 00 00 02 00 03 00 03 00 03
|
||||||
|
rx_telegram({0x10, 0x48, 0xFF, 00, 01, 0x6B, 00, 0x6B, 0x08, 0x4F, 00, 00, 00, 02, 00, 00, 00, 02, 00, 03, 00, 03, 00, 03});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(command, "boiler") == 0) {
|
||||||
|
// EMSESP::logger().info(F("Testing boiler..."));
|
||||||
|
add_device(0x08, 123); // Nefit Trendline
|
||||||
|
|
||||||
|
// UBAuptime
|
||||||
|
uart_telegram({0x08, 0x0B, 0x14, 00, 0x3C, 0x1F, 0xAC, 0x70});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(command, "thermostat") == 0) {
|
||||||
|
EMSESP::logger().info(F("Testing thermostat..."));
|
||||||
|
add_device(0x10, 192); // FW120
|
||||||
|
|
||||||
|
// 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});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(command, "solar") == 0) {
|
||||||
|
EMSESP::logger().info(F("Testing solar..."));
|
||||||
|
EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS);
|
||||||
|
|
||||||
|
add_device(0x30, 163); // SM100
|
||||||
|
|
||||||
|
// SM100Monitor - type 0x0362 EMS+ - for SM100 and SM200
|
||||||
|
// B0 0B FF 00 02 62 00 44 02 7A 80 00 80 00 80 00 80 00 80 00 80 00 00 7C 80 00 80 00 80 00 80
|
||||||
|
rx_telegram({0xB0, 0x0B, 0xFF, 00, 0x02, 0x62, 00, 0x44, 0x02, 0x7A, 0x80, 00, 0x80, 0x00, 0x80, 00,
|
||||||
|
0x80, 00, 0x80, 00, 0x80, 00, 00, 0x7C, 0x80, 00, 0x80, 00, 0x80, 00, 0x80});
|
||||||
|
|
||||||
|
rx_telegram({0xB0, 0x0B, 0xFF, 0x00, 0x02, 0x62, 0x01, 0x44, 0x03, 0x30, 0x80, 00, 0x80, 00, 0x80, 00,
|
||||||
|
0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 0x33});
|
||||||
|
|
||||||
|
rx_telegram({0xB0, 00, 0xFF, 0x18, 02, 0x62, 0x80, 00, 0xB8});
|
||||||
|
|
||||||
|
EMSESP::send_raw_telegram("B0 00 FF 18 02 62 80 00 B8");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(command, "heatpump") == 0) {
|
||||||
|
EMSESP::logger().info(F("Testing heatpump..."));
|
||||||
|
EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS);
|
||||||
|
add_device(0x38, 200); // Enviline module
|
||||||
|
add_device(0x10, 192); // FW120 thermostat
|
||||||
|
|
||||||
|
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}); // HC1
|
||||||
|
|
||||||
|
uart_telegram("38 0B FF 00 03 7B 0C 34 00 74");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// used with the 'test' command, under su/admin
|
// used with the 'test' command, under su/admin
|
||||||
void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
void Test::run_test_shell(uuid::console::Shell & shell, const std::string & command) {
|
||||||
// switch to su
|
// switch to su
|
||||||
shell.add_flags(CommandFlags::ADMIN);
|
shell.add_flags(CommandFlags::ADMIN);
|
||||||
|
|
||||||
if (command == "default") {
|
if ((command == "default") || (command == "general") || (command.empty())) {
|
||||||
run_test(shell, "general"); // add the default test case here
|
shell.printfln(F("Testing adding a general boiler & thermostat..."));
|
||||||
}
|
run_test("general");
|
||||||
|
shell.invoke_command("show devices");
|
||||||
if (command.empty()) {
|
shell.invoke_command("show");
|
||||||
run_test(shell, "default");
|
shell.invoke_command("call system publish");
|
||||||
|
shell.invoke_command("show mqtt");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "render") {
|
if (command == "render") {
|
||||||
@@ -139,8 +255,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
|
|
||||||
EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); // this is important otherwise nothing will be picked up!
|
EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); // this is important otherwise nothing will be picked up!
|
||||||
|
|
||||||
//emsdevices.push_back(EMSFactory::add(EMSdevice::DeviceType::BOILER, EMSdevice::EMS_DEVICE_ID_BOILER, 0, "", "My Boiler", 0, 0));
|
|
||||||
|
|
||||||
// A fake response - UBADevices(0x07)
|
// A fake response - UBADevices(0x07)
|
||||||
rx_telegram({0x08, 0x00, 0x07, 0x00, 0x0B, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
|
rx_telegram({0x08, 0x00, 0x07, 0x00, 0x0B, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
|
||||||
}
|
}
|
||||||
@@ -160,9 +274,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
if (command == "unknown") {
|
if (command == "unknown") {
|
||||||
shell.printfln(F("Testing unknown..."));
|
shell.printfln(F("Testing unknown..."));
|
||||||
|
|
||||||
// question: do we need to set the mask?
|
|
||||||
std::string version("1.2.3");
|
|
||||||
|
|
||||||
// add boiler
|
// add boiler
|
||||||
add_device(0x08, 84);
|
add_device(0x08, 84);
|
||||||
|
|
||||||
@@ -186,20 +297,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
|
|
||||||
if (command == "gateway") {
|
if (command == "gateway") {
|
||||||
shell.printfln(F("Testing Gateway..."));
|
shell.printfln(F("Testing Gateway..."));
|
||||||
|
run_test("gateway");
|
||||||
// add 0x48 KM200, via a version command
|
|
||||||
rx_telegram({0x48, 0x0B, 0x02, 0x00, 0xBD, 0x04, 0x06, 00, 00, 00, 00, 00, 00, 00});
|
|
||||||
|
|
||||||
// Boiler(0x08) -> All(0x00), UBADevices(0x07), data: 09 01 00 00 00 00 00 00 01 00 00 00 00
|
|
||||||
// check: make sure 0x48 is not detected again !
|
|
||||||
rx_telegram({0x08, 0x00, 0x07, 0x00, 0x09, 01, 00, 00, 00, 00, 00, 00, 01, 00, 00, 00, 00});
|
|
||||||
|
|
||||||
// add thermostat - Thermostat: RC300/RC310/Moduline 3000/CW400/Sense II (DeviceID:0x10, ProductID:158, Version:03.03) ** master device **
|
|
||||||
add_device(0x10, 158); // Nefit Trendline
|
|
||||||
|
|
||||||
// simulate incoming telegram
|
|
||||||
// Thermostat(0x10) -> 48(0x48), ?(0x26B), data: 6B 08 4F 00 00 00 02 00 00 00 02 00 03 00 03 00 03
|
|
||||||
rx_telegram({0x10, 0x48, 0xFF, 00, 01, 0x6B, 00, 0x6B, 0x08, 0x4F, 00, 00, 00, 02, 00, 00, 00, 02, 00, 03, 00, 03, 00, 03});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "web") {
|
if (command == "web") {
|
||||||
@@ -227,8 +325,9 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
uart_telegram({0x98, 0x00, 0x06, 0x00, 0x00, 0x03, 0x04, 0x0C, 0x02, 0x33, 0x06, 00, 00, 00, 00, 00, 00});
|
uart_telegram({0x98, 0x00, 0x06, 0x00, 0x00, 0x03, 0x04, 0x0C, 0x02, 0x33, 0x06, 00, 00, 00, 00, 00, 00});
|
||||||
|
|
||||||
shell.invoke_command("show");
|
shell.invoke_command("show");
|
||||||
StaticJsonDocument<2000> doc;
|
|
||||||
JsonObject root = doc.to<JsonObject>();
|
StaticJsonDocument<500> doc;
|
||||||
|
JsonObject root = doc.to<JsonObject>();
|
||||||
EMSESP::device_info_web(2, root); // show thermostat. use 1 for boiler
|
EMSESP::device_info_web(2, root); // show thermostat. use 1 for boiler
|
||||||
serializeJsonPretty(doc, shell);
|
serializeJsonPretty(doc, shell);
|
||||||
shell.println();
|
shell.println();
|
||||||
@@ -236,48 +335,15 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
|
|
||||||
if (command == "boiler") {
|
if (command == "boiler") {
|
||||||
shell.printfln(F("Testing boiler..."));
|
shell.printfln(F("Testing boiler..."));
|
||||||
|
run_test("boiler");
|
||||||
add_device(0x08, 123); // Nefit Trendline
|
|
||||||
|
|
||||||
// UBAuptime
|
|
||||||
uart_telegram({0x08, 0x0B, 0x14, 00, 0x3C, 0x1F, 0xAC, 0x70});
|
|
||||||
|
|
||||||
shell.invoke_command("show");
|
shell.invoke_command("show");
|
||||||
shell.invoke_command("call boiler info");
|
shell.invoke_command("call boiler info");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "general") {
|
|
||||||
shell.printfln(F("Testing adding a general boiler & thermostat..."));
|
|
||||||
|
|
||||||
add_device(0x08, 123); // Nefit Trendline
|
|
||||||
add_device(0x18, 157); // Bosch CR100
|
|
||||||
|
|
||||||
// add some data
|
|
||||||
// Boiler -> Me, UBAMonitorFast(0x18), telegram: 08 00 18 00 00 02 5A 73 3D 0A 10 65 40 02 1A 80 00 01 E1 01 76 0E 3D 48 00 C9 44 02 00 (#data=25)
|
|
||||||
uart_telegram({0x08, 0x00, 0x18, 0x00, 0x00, 0x02, 0x5A, 0x73, 0x3D, 0x0A, 0x10, 0x65, 0x40, 0x02, 0x1A,
|
|
||||||
0x80, 0x00, 0x01, 0xE1, 0x01, 0x76, 0x0E, 0x3D, 0x48, 0x00, 0xC9, 0x44, 0x02, 0x00});
|
|
||||||
|
|
||||||
// Boiler -> Thermostat, UBAParameterWW(0x33), telegram: 08 97 33 00 23 24 (#data=2)
|
|
||||||
uart_telegram({0x08, 0x98, 0x33, 0x00, 0x23, 0x24});
|
|
||||||
|
|
||||||
// Boiler -> Me, UBAParameterWW(0x33), telegram: 08 0B 33 00 08 FF 34 FB 00 28 00 00 46 00 FF FF 00 (#data=13)
|
|
||||||
uart_telegram({0x08, 0x0B, 0x33, 0x00, 0x08, 0xFF, 0x34, 0xFB, 0x00, 0x28, 0x00, 0x00, 0x46, 0x00, 0xFF, 0xFF, 0x00});
|
|
||||||
|
|
||||||
// Thermostat RCPLUSStatusMessage_HC1(0x01A5)
|
|
||||||
uart_telegram({0x98, 0x00, 0xFF, 0x00, 0x01, 0xA5, 0x00, 0xCF, 0x21, 0x2E, 0x00, 0x00, 0x2E, 0x24,
|
|
||||||
0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03});
|
|
||||||
|
|
||||||
shell.invoke_command("show devices");
|
|
||||||
shell.invoke_command("show");
|
|
||||||
shell.invoke_command("call system publish");
|
|
||||||
shell.invoke_command("show mqtt");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command == "fr120") {
|
if (command == "fr120") {
|
||||||
shell.printfln(F("Testing adding a thermostat FR120..."));
|
shell.printfln(F("Testing adding a thermostat FR120..."));
|
||||||
|
|
||||||
// add a thermostat
|
add_device(0x10, 191); // FR120 thermostat
|
||||||
add_device(0x10, 191); // FR120
|
|
||||||
|
|
||||||
// HC1
|
// HC1
|
||||||
uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x6F, 0x00, 0xCF, 0x21, 0x2E, 0x20, 0x00, 0x2E, 0x24,
|
uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x6F, 0x00, 0xCF, 0x21, 0x2E, 0x20, 0x00, 0x2E, 0x24,
|
||||||
@@ -289,23 +355,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
|
|
||||||
if (command == "thermostat") {
|
if (command == "thermostat") {
|
||||||
shell.printfln(F("Testing adding a thermostat FW120..."));
|
shell.printfln(F("Testing adding a thermostat FW120..."));
|
||||||
|
run_test("thermostat");
|
||||||
// add a thermostat
|
|
||||||
add_device(0x10, 192); // FW120
|
|
||||||
|
|
||||||
// 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});
|
|
||||||
|
|
||||||
shell.invoke_command("show");
|
shell.invoke_command("show");
|
||||||
|
|
||||||
EMSESP::mqtt_.incoming("ems-esp/thermostat_hc1", "heat");
|
EMSESP::mqtt_.incoming("ems-esp/thermostat_hc1", "heat");
|
||||||
EMSESP::mqtt_.incoming("ems-esp/thermostat_hc2", "28.8");
|
EMSESP::mqtt_.incoming("ems-esp/thermostat_hc2", "28.8");
|
||||||
EMSESP::mqtt_.incoming("ems-esp/thermostat", "{\"cmd\":\"temp\",\"id\":2,\"data\":22}");
|
EMSESP::mqtt_.incoming("ems-esp/thermostat", "{\"cmd\":\"temp\",\"id\":2,\"data\":22}");
|
||||||
@@ -324,50 +375,19 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
|
|
||||||
if (command == "solar") {
|
if (command == "solar") {
|
||||||
shell.printfln(F("Testing Solar"));
|
shell.printfln(F("Testing Solar"));
|
||||||
|
run_test("solar");
|
||||||
EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS);
|
|
||||||
|
|
||||||
add_device(0x30, 163); // SM100
|
|
||||||
|
|
||||||
// SM100Monitor - type 0x0362 EMS+ - for SM100 and SM200
|
|
||||||
// B0 0B FF 00 02 62 00 44 02 7A 80 00 80 00 80 00 80 00 80 00 80 00 00 7C 80 00 80 00 80 00 80
|
|
||||||
rx_telegram({0xB0, 0x0B, 0xFF, 00, 0x02, 0x62, 00, 0x44, 0x02, 0x7A, 0x80, 00, 0x80, 0x00, 0x80, 00,
|
|
||||||
0x80, 00, 0x80, 00, 0x80, 00, 00, 0x7C, 0x80, 00, 0x80, 00, 0x80, 00, 0x80});
|
|
||||||
|
|
||||||
rx_telegram({0xB0, 0x0B, 0xFF, 0x00, 0x02, 0x62, 0x01, 0x44, 0x03, 0x30, 0x80, 00, 0x80, 00, 0x80, 00,
|
|
||||||
0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 0x33});
|
|
||||||
|
|
||||||
rx_telegram({0xB0, 00, 0xFF, 0x18, 02, 0x62, 0x80, 00, 0xB8});
|
|
||||||
|
|
||||||
EMSESP::send_raw_telegram("B0 00 FF 18 02 62 80 00 B8");
|
|
||||||
|
|
||||||
uart_telegram("30 00 FF 0A 02 6A 04"); // SM100 pump on 1
|
uart_telegram("30 00 FF 0A 02 6A 04"); // SM100 pump on 1
|
||||||
uart_telegram("30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0B 09 64 00 00 00 00"); // SM100 modulation
|
uart_telegram("30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0B 09 64 00 00 00 00"); // SM100 modulation
|
||||||
EMSESP::show_device_values(shell);
|
EMSESP::show_device_values(shell);
|
||||||
|
|
||||||
uart_telegram("30 00 FF 0A 02 6A 03"); // SM100 pump off 0
|
uart_telegram("30 00 FF 0A 02 6A 03"); // SM100 pump off 0
|
||||||
EMSESP::show_device_values(shell);
|
EMSESP::show_device_values(shell);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "heatpump") {
|
if (command == "heatpump") {
|
||||||
shell.printfln(F("Testing Heat Pump"));
|
shell.printfln(F("Testing Heat Pump"));
|
||||||
|
run_test("heatpump");
|
||||||
EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS);
|
|
||||||
|
|
||||||
// add heatpump
|
|
||||||
add_device(0x38, 200); // Enviline module
|
|
||||||
|
|
||||||
// add a thermostat
|
|
||||||
add_device(0x10, 192); // FW120
|
|
||||||
|
|
||||||
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}); // HC1
|
|
||||||
|
|
||||||
uart_telegram("38 0B FF 00 03 7B 0C 34 00 74");
|
|
||||||
shell.invoke_command("call");
|
shell.invoke_command("call");
|
||||||
shell.invoke_command("call heatpump info");
|
shell.invoke_command("call heatpump info");
|
||||||
|
|
||||||
EMSESP::show_device_values(shell);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "solar200") {
|
if (command == "solar200") {
|
||||||
@@ -381,25 +401,20 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
// B0 0B FF 00 02 62 00 44 02 7A 80 00 80 00 80 00 80 00 80 00 80 00 00 7C 80 00 80 00 80 00 80
|
// B0 0B FF 00 02 62 00 44 02 7A 80 00 80 00 80 00 80 00 80 00 80 00 00 7C 80 00 80 00 80 00 80
|
||||||
rx_telegram({0xB0, 0x0B, 0xFF, 00, 0x02, 0x62, 00, 0x44, 0x02, 0x7A, 0x80, 00, 0x80, 0x00, 0x80, 00,
|
rx_telegram({0xB0, 0x0B, 0xFF, 00, 0x02, 0x62, 00, 0x44, 0x02, 0x7A, 0x80, 00, 0x80, 0x00, 0x80, 00,
|
||||||
0x80, 00, 0x80, 00, 0x80, 00, 00, 0x7C, 0x80, 00, 0x80, 00, 0x80, 00, 0x80});
|
0x80, 00, 0x80, 00, 0x80, 00, 00, 0x7C, 0x80, 00, 0x80, 00, 0x80, 00, 0x80});
|
||||||
EMSESP::show_device_values(shell);
|
|
||||||
|
|
||||||
rx_telegram({0xB0, 0x0B, 0xFF, 0x00, 0x02, 0x62, 0x01, 0x44, 0x03, 0x30, 0x80, 00, 0x80, 00, 0x80, 00,
|
rx_telegram({0xB0, 0x0B, 0xFF, 0x00, 0x02, 0x62, 0x01, 0x44, 0x03, 0x30, 0x80, 00, 0x80, 00, 0x80, 00,
|
||||||
0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 0x33});
|
0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 0x33});
|
||||||
EMSESP::show_device_values(shell);
|
|
||||||
|
|
||||||
rx_telegram({0xB0, 00, 0xFF, 0x18, 02, 0x62, 0x80, 00, 0xB8});
|
rx_telegram({0xB0, 00, 0xFF, 0x18, 02, 0x62, 0x80, 00, 0xB8});
|
||||||
EMSESP::show_device_values(shell);
|
|
||||||
|
|
||||||
EMSESP::send_raw_telegram("B0 00 FF 18 02 62 80 00 B8");
|
EMSESP::send_raw_telegram("B0 00 FF 18 02 62 80 00 B8");
|
||||||
|
|
||||||
uart_telegram("30 00 FF 0A 02 6A 04"); // SM100 pump on 1
|
uart_telegram("30 00 FF 0A 02 6A 04"); // SM100 pump on 1
|
||||||
uart_telegram("30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0B 09 64 00 00 00 00"); // SM100 modulation
|
uart_telegram("30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0B 09 64 00 00 00 00"); // SM100 modulation
|
||||||
|
|
||||||
EMSESP::show_device_values(shell);
|
|
||||||
|
|
||||||
uart_telegram("30 00 FF 0A 02 6A 03"); // SM100 pump off 0
|
uart_telegram("30 00 FF 0A 02 6A 03"); // SM100 pump off 0
|
||||||
|
|
||||||
EMSESP::show_device_values(shell);
|
shell.invoke_command("show");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "km") {
|
if (command == "km") {
|
||||||
@@ -558,12 +573,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
uart_telegram({0x88, 00, 0x2A, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0xD2, 00, 00, 0x80, 00, 00, 01, 0x9D, 0x80, 0x00, 0x02, 0x79, 00});
|
uart_telegram({0x88, 00, 0x2A, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0xD2, 00, 00, 0x80, 00, 00, 01, 0x9D, 0x80, 0x00, 0x02, 0x79, 00});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "send") {
|
|
||||||
shell.printfln(F("Sending to Tx..."));
|
|
||||||
EMSESP::show_ems(shell);
|
|
||||||
EMSESP::txservice_.send(); // send it to UART
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command == "tx") {
|
if (command == "tx") {
|
||||||
shell.printfln(F("Testing Tx..."));
|
shell.printfln(F("Testing Tx..."));
|
||||||
|
|
||||||
@@ -602,8 +611,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
EMSESP::txservice_.send(); // send it to UART
|
EMSESP::txservice_.send(); // send it to UART
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.loop_all();
|
|
||||||
|
|
||||||
EMSESP::txservice_.flush_tx_queue();
|
EMSESP::txservice_.flush_tx_queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -654,9 +661,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
shell.invoke_command("call");
|
shell.invoke_command("call");
|
||||||
shell.invoke_command("call system info");
|
shell.invoke_command("call system info");
|
||||||
|
|
||||||
char system_topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
EMSESP::mqtt_.incoming("ems-esp/system", "{\"cmd\":\"info\"}"); // this should fail
|
||||||
strcpy(system_topic, "ems-esp/system");
|
|
||||||
EMSESP::mqtt_.incoming(system_topic, "{\"cmd\":\"info\"}"); // this should fail
|
|
||||||
|
|
||||||
shell.invoke_command("call thermostat wwmode"); // should do nothing
|
shell.invoke_command("call thermostat wwmode"); // should do nothing
|
||||||
shell.invoke_command("call thermostat mode auto 2"); // should error, no hc2
|
shell.invoke_command("call thermostat mode auto 2"); // should error, no hc2
|
||||||
@@ -665,8 +670,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
|
|
||||||
if (command == "pin") {
|
if (command == "pin") {
|
||||||
shell.printfln(F("Testing pin..."));
|
shell.printfln(F("Testing pin..."));
|
||||||
|
|
||||||
shell.invoke_command("su");
|
|
||||||
shell.invoke_command("call system pin");
|
shell.invoke_command("call system pin");
|
||||||
shell.invoke_command("call system pin 1 true");
|
shell.invoke_command("call system pin 1 true");
|
||||||
}
|
}
|
||||||
@@ -819,10 +822,10 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
|
|||||||
// check for error "No telegram type handler found for ID 0x255 (src 0x20)"
|
// check for error "No telegram type handler found for ID 0x255 (src 0x20)"
|
||||||
uart_telegram({0xA0, 0x00, 0xFF, 0x00, 0x01, 0x55, 0x00, 0x1A});
|
uart_telegram({0xA0, 0x00, 0xFF, 0x00, 0x01, 0x55, 0x00, 0x1A});
|
||||||
|
|
||||||
shell.invoke_command("show");
|
// shell.invoke_command("show");
|
||||||
shell.invoke_command("call mixer info");
|
// shell.invoke_command("call mixer info");
|
||||||
shell.invoke_command("call system publish");
|
// shell.invoke_command("call system publish");
|
||||||
shell.invoke_command("show mqtt");
|
// shell.invoke_command("show mqtt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_TEST)
|
||||||
|
|
||||||
#ifndef EMSESP_TEST_H
|
#ifndef EMSESP_TEST_H
|
||||||
#define EMSESP_TEST_H
|
#define EMSESP_TEST_H
|
||||||
@@ -40,7 +40,8 @@ namespace emsesp {
|
|||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
public:
|
public:
|
||||||
static void run_test(uuid::console::Shell & shell, const std::string & command);
|
static void run_test_shell(uuid::console::Shell & shell, const std::string & command);
|
||||||
|
static void run_test(const char * command, int8_t id = 0);
|
||||||
static void dummy_mqtt_commands(const char * message);
|
static void dummy_mqtt_commands(const char * message);
|
||||||
static void rx_telegram(const std::vector<uint8_t> & data);
|
static void rx_telegram(const std::vector<uint8_t> & data);
|
||||||
static void uart_telegram(const std::vector<uint8_t> & rx_data);
|
static void uart_telegram(const std::vector<uint8_t> & rx_data);
|
||||||
|
|||||||
Reference in New Issue
Block a user