mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
Merge pull request #1272 from proddy/dev
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -41,5 +41,6 @@
|
|||||||
"**/*.min.*",
|
"**/*.min.*",
|
||||||
"**/*.map",
|
"**/*.map",
|
||||||
"**/ArduinoJson/**"
|
"**/ArduinoJson/**"
|
||||||
]
|
],
|
||||||
|
"cSpell.enableFiletypes": ["!cpp"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"adapter": "react",
|
"adapter": "react",
|
||||||
"baseLocale": "pl",
|
"baseLocale": "pl",
|
||||||
"$schema": "https://unpkg.com/typesafe-i18n@5.26.1/schema/typesafe-i18n.json"
|
"$schema": "https://unpkg.com/typesafe-i18n@5.26.2/schema/typesafe-i18n.json"
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
"build-hosted": "vite build --mode hosted",
|
"build-hosted": "vite build --mode hosted",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"preview-standalone": "npm-run-all -p preview typesafe-i18n mock-api",
|
"preview-standalone": "npm-run-all -p preview typesafe-i18n mock-api",
|
||||||
"mock-api": "nodemon --watch ../mock-api ../mock-api/server.js",
|
"mock-api": "node --watch ../mock-api ../mock-api/server.js",
|
||||||
"standalone": "npm-run-all -p dev typesafe-i18n mock-api",
|
"standalone": "npm-run-all -p dev typesafe-i18n mock-api",
|
||||||
"typesafe-i18n": "typesafe-i18n",
|
"typesafe-i18n": "typesafe-i18n",
|
||||||
"format": "prettier --write '**/*.{ts,tsx,js,css,json,md}'",
|
"format": "prettier --write '**/*.{ts,tsx,js,css,json,md}'",
|
||||||
@@ -22,17 +22,17 @@
|
|||||||
"@alova/adapter-xhr": "^1.0.1",
|
"@alova/adapter-xhr": "^1.0.1",
|
||||||
"@emotion/react": "^11.11.1",
|
"@emotion/react": "^11.11.1",
|
||||||
"@emotion/styled": "^11.11.0",
|
"@emotion/styled": "^11.11.0",
|
||||||
"@mui/icons-material": "^5.14.3",
|
"@mui/icons-material": "^5.14.7",
|
||||||
"@mui/material": "^5.14.5",
|
"@mui/material": "^5.14.7",
|
||||||
"@preact/compat": "^17.1.2",
|
"@preact/compat": "^17.1.2",
|
||||||
"@prefresh/vite": "^2.4.1",
|
"@prefresh/vite": "^2.4.1",
|
||||||
"@table-library/react-table-library": "4.1.7",
|
"@table-library/react-table-library": "4.1.7",
|
||||||
"@types/lodash-es": "^4.17.8",
|
"@types/lodash-es": "^4.17.8",
|
||||||
"@types/node": "^20.5.1",
|
"@types/node": "^20.5.7",
|
||||||
"@types/react": "^18.2.20",
|
"@types/react": "^18.2.21",
|
||||||
"@types/react-dom": "^18.2.7",
|
"@types/react-dom": "^18.2.7",
|
||||||
"@types/react-router-dom": "^5.3.3",
|
"@types/react-router-dom": "^5.3.3",
|
||||||
"alova": "^2.11.0",
|
"alova": "^2.11.1",
|
||||||
"async-validator": "^4.2.5",
|
"async-validator": "^4.2.5",
|
||||||
"history": "^5.3.0",
|
"history": "^5.3.0",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
@@ -46,16 +46,16 @@
|
|||||||
"react-router-dom": "^6.15.0",
|
"react-router-dom": "^6.15.0",
|
||||||
"react-toastify": "^9.1.3",
|
"react-toastify": "^9.1.3",
|
||||||
"sockette": "^2.0.6",
|
"sockette": "^2.0.6",
|
||||||
"typesafe-i18n": "^5.26.1",
|
"typesafe-i18n": "^5.26.2",
|
||||||
"typescript": "^5.1.6"
|
"typescript": "^5.2.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.22.10",
|
"@babel/core": "^7.22.11",
|
||||||
"@preact/preset-vite": "^2.5.0",
|
"@preact/preset-vite": "^2.5.0",
|
||||||
"@types/babel__core": "^7",
|
"@types/babel__core": "^7",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.4.0",
|
"@typescript-eslint/eslint-plugin": "^6.5.0",
|
||||||
"@typescript-eslint/parser": "^6.4.0",
|
"@typescript-eslint/parser": "^6.5.0",
|
||||||
"eslint": "^8.47.0",
|
"eslint": "^8.48.0",
|
||||||
"eslint-config-airbnb": "^19.0.4",
|
"eslint-config-airbnb": "^19.0.4",
|
||||||
"eslint-config-airbnb-typescript": "^17.1.0",
|
"eslint-config-airbnb-typescript": "^17.1.0",
|
||||||
"eslint-config-prettier": "^9.0.0",
|
"eslint-config-prettier": "^9.0.0",
|
||||||
@@ -66,11 +66,10 @@
|
|||||||
"eslint-plugin-prettier": "alpha",
|
"eslint-plugin-prettier": "alpha",
|
||||||
"eslint-plugin-react": "^7.33.2",
|
"eslint-plugin-react": "^7.33.2",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
"nodemon": "^3.0.1",
|
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"prettier": "^3.0.2",
|
"prettier": "^3.0.3",
|
||||||
"rollup-plugin-visualizer": "^5.9.2",
|
"rollup-plugin-visualizer": "^5.9.2",
|
||||||
"terser": "^5.19.2",
|
"terser": "^5.19.3",
|
||||||
"vite": "^4.4.9",
|
"vite": "^4.4.9",
|
||||||
"vite-plugin-svgr": "^3.2.0",
|
"vite-plugin-svgr": "^3.2.0",
|
||||||
"vite-tsconfig-paths": "^4.2.0"
|
"vite-tsconfig-paths": "^4.2.0"
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ export default defineConfig(({ command, mode }) => {
|
|||||||
server: {
|
server: {
|
||||||
open: true,
|
open: true,
|
||||||
port: 3000,
|
port: 3000,
|
||||||
watch: {
|
// watch: {
|
||||||
usePolling: true
|
// usePolling: true
|
||||||
},
|
// },
|
||||||
proxy: {
|
proxy: {
|
||||||
'/rest': 'http://localhost:3080',
|
'/rest': 'http://localhost:3080',
|
||||||
'/api': {
|
'/api': {
|
||||||
|
|||||||
1105
interface/yarn.lock
1105
interface/yarn.lock
File diff suppressed because it is too large
Load Diff
@@ -5,15 +5,14 @@
|
|||||||
"author": "proddy",
|
"author": "proddy",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "nodemon ./server.js localhost 3080",
|
"dev": "node --watch ./server.js localhost 3080",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@msgpack/msgpack": "^2.8.0",
|
"@msgpack/msgpack": "^2.8.0",
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.7.4",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"multer": "^1.4.5-lts.1",
|
"multer": "^1.4.5-lts.1"
|
||||||
"nodemon": "^3.0.1"
|
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@3.4.1"
|
"packageManager": "yarn@3.4.1"
|
||||||
}
|
}
|
||||||
|
|||||||
1115
mock-api/yarn.lock
1115
mock-api/yarn.lock
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,21 @@
|
|||||||
# testing EMS-ESP API
|
# testing EMS-ESP API
|
||||||
# use with https://marketplace.visualstudio.com/items?itemName=humao.rest-client
|
# use with "REST Client" extension in Visual Studio Code
|
||||||
|
# https://marketplace.visualstudio.com/items?itemName=humao.rest-client
|
||||||
|
|
||||||
|
@host = http://ems-esp.local
|
||||||
|
@host_dev = http://ems-esp2.local
|
||||||
|
|
||||||
@token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiYWRtaW4iOnRydWV9.2bHpWya2C7Q12WjNUBD6_7N3RCD7CMl-EGhyQVzFdDg
|
@token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiYWRtaW4iOnRydWV9.2bHpWya2C7Q12WjNUBD6_7N3RCD7CMl-EGhyQVzFdDg
|
||||||
|
|
||||||
GET http://ems-esp.local/api/system/info
|
GET {{host}}/api/system/info
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
GET http://ems-esp.local/api/thermostat/seltemp
|
GET {{host}}/api/thermostat/seltemp
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
POST http://ems-esp.local/api/thermostat/seltemp
|
POST {{host}}/api/thermostat/seltemp
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
@@ -21,7 +25,7 @@ Authorization: Bearer {{token}}
|
|||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
POST http://ems-esp.local/api/thermostat
|
POST {{host}}/api/thermostat
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
@@ -32,12 +36,61 @@ Authorization: Bearer {{token}}
|
|||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
POST http://10.10.10.134/api
|
POST {{host}}/api
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiYWRtaW4iOnRydWV9.2bHpWya2C7Q12WjNUBD6_7N3RCD7CMl-EGhyQVzFdDg
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
{
|
{
|
||||||
"device" : "boiler",
|
"device" : "boiler",
|
||||||
"entity" : "wwtapactivated",
|
"entity" : "wwtapactivated",
|
||||||
"value" : "on"
|
"value" : "on"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
GET {{host}}/api/system/restart
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
GET {{host}}/api/boiler/coldshot
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
GET {{host}}/api/temperaturesensor/info
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test on dev
|
||||||
|
#
|
||||||
|
|
||||||
|
GET {{host_dev}}/api/system/info
|
||||||
|
|
||||||
|
# Run a test. EMS-ESP must be compiled with -DEMSESP_TEST
|
||||||
|
# Use this to load up a dummy thermostat and boiler with data
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
GET {{host_dev}}/api?device=system&cmd=test&data=general
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
GET {{host_dev}}/api/boiler/info
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{host_dev}}/api/boiler/values
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
GET {{host_dev}}/api/analogsensor/info
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
GET {{host_dev}}/api/boiler/coldshot
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{host_dev}}/api/system/commands
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
|
|||||||
if (!strncmp(path, Mqtt::base().c_str(), Mqtt::base().length())) {
|
if (!strncmp(path, Mqtt::base().c_str(), Mqtt::base().length())) {
|
||||||
char new_path[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
char new_path[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
strlcpy(new_path, path, sizeof(new_path));
|
strlcpy(new_path, path, sizeof(new_path));
|
||||||
p.parse(new_path + Mqtt::base().length() + 1); // re-parse the stripped path
|
p.parse(new_path + Mqtt::base().length() + 1); // re-parse the stripped path
|
||||||
} else {
|
} else {
|
||||||
return message(CommandRet::ERROR, "unrecognized path", output); // error
|
return message(CommandRet::ERROR, "unrecognized path", output); // error
|
||||||
}
|
}
|
||||||
@@ -194,7 +194,7 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
|
|||||||
} else if (data.isNull()) {
|
} else if (data.isNull()) {
|
||||||
return_code = Command::call(device_type, command_p, "", is_admin, id_n, output); // empty, will do a query instead
|
return_code = Command::call(device_type, command_p, "", is_admin, id_n, output); // empty, will do a query instead
|
||||||
} else {
|
} else {
|
||||||
return message(CommandRet::ERROR, "cannot parse command", output); // can't process
|
return message(CommandRet::ERROR, "cannot parse command", output); // can't process
|
||||||
}
|
}
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
@@ -301,9 +301,14 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
|
|||||||
auto cf = find_command(device_type, device_id, cmd);
|
auto cf = find_command(device_type, device_id, cmd);
|
||||||
|
|
||||||
// check if its a call to and end-point to a device
|
// check if its a call to and end-point to a device
|
||||||
// except for system commands as this is a special device without any queryable entities (device values)
|
// this is used to fetch the attributes of the device entity, or call a command directly
|
||||||
if ((device_type > EMSdevice::DeviceType::SYSTEM) && (!value || !strlen(value))) {
|
bool single_command = (!value || !strlen(value));
|
||||||
if (!cf || !cf->cmdfunction_json_) {
|
if (single_command) {
|
||||||
|
// exception 1: anything that is from System
|
||||||
|
// exception 2: boiler coldshot command
|
||||||
|
bool get_attributes = (!cf || !cf->cmdfunction_json_) && (device_type > EMSdevice::DeviceType::SYSTEM) && (strcmp(cmd, F_(coldshot)) != 0);
|
||||||
|
|
||||||
|
if (get_attributes) {
|
||||||
LOG_DEBUG("Calling %s command '%s' to retrieve attributes", dname, cmd);
|
LOG_DEBUG("Calling %s command '%s' to retrieve attributes", dname, cmd);
|
||||||
return EMSESP::get_device_value_info(output, cmd, id, device_type) ? CommandRet::OK : CommandRet::ERROR; // entity = cmd
|
return EMSESP::get_device_value_info(output, cmd, id, device_type) ? CommandRet::OK : CommandRet::ERROR; // entity = cmd
|
||||||
}
|
}
|
||||||
@@ -344,7 +349,7 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
|
|||||||
|
|
||||||
// check if read-only. This also checks for valid tags (e.g. heating circuits)
|
// check if read-only. This also checks for valid tags (e.g. heating circuits)
|
||||||
if (cf->cmdfunction_) {
|
if (cf->cmdfunction_) {
|
||||||
if (EMSESP::cmd_is_readonly(device_type, device_id, cmd, id)) {
|
if (!single_command && EMSESP::cmd_is_readonly(device_type, device_id, cmd, id)) {
|
||||||
return_code = CommandRet::INVALID; // readonly or invalid hc
|
return_code = CommandRet::INVALID; // readonly or invalid hc
|
||||||
} else {
|
} else {
|
||||||
return_code = ((cf->cmdfunction_)(value, id)) ? CommandRet::OK : CommandRet::ERROR;
|
return_code = ((cf->cmdfunction_)(value, id)) ? CommandRet::OK : CommandRet::ERROR;
|
||||||
@@ -593,7 +598,7 @@ void Command::show_devices(uuid::console::Shell & shell) {
|
|||||||
// output list of all commands to console
|
// output list of all commands to console
|
||||||
// calls show with verbose mode set
|
// calls show with verbose mode set
|
||||||
void Command::show_all(uuid::console::Shell & shell) {
|
void Command::show_all(uuid::console::Shell & shell) {
|
||||||
shell.println("Available commands (*=do not need authorization): ");
|
shell.println("Available commands (*=authorization not required): ");
|
||||||
|
|
||||||
// show system first
|
// show system first
|
||||||
shell.print(COLOR_BOLD_ON);
|
shell.print(COLOR_BOLD_ON);
|
||||||
|
|||||||
@@ -137,6 +137,9 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
|||||||
Test::run_test(shell, arguments[0].c_str(), arguments[1].c_str());
|
Test::run_test(shell, arguments[0].c_str(), arguments[1].c_str());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
commands->add_command(ShellContext::MAIN, CommandFlags::USER, string_vector{"t"}, [=](Shell & shell, const std::vector<std::string> & arguments) {
|
||||||
|
Test::run_test(shell, "default");
|
||||||
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
commands->add_command(ShellContext::MAIN, CommandFlags::USER, string_vector{F_(su)}, [=](Shell & shell, const std::vector<std::string> & arguments) {
|
commands->add_command(ShellContext::MAIN, CommandFlags::USER, string_vector{F_(su)}, [=](Shell & shell, const std::vector<std::string> & arguments) {
|
||||||
@@ -419,7 +422,6 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
|||||||
to_app(shell).send_read_request(type_id, device_id, 0, EMS_MAX_TELEGRAM_LENGTH, true);
|
to_app(shell).send_read_request(type_id, device_id, 0, EMS_MAX_TELEGRAM_LENGTH, true);
|
||||||
}
|
}
|
||||||
to_app(shell).set_read_id(type_id);
|
to_app(shell).set_read_id(type_id);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
commands->add_command(ShellContext::MAIN,
|
commands->add_command(ShellContext::MAIN,
|
||||||
@@ -433,11 +435,11 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
|||||||
if (!arguments.empty()) {
|
if (!arguments.empty()) {
|
||||||
// get raw/pretty
|
// get raw/pretty
|
||||||
if (arguments[0] == (F_(raw))) {
|
if (arguments[0] == (F_(raw))) {
|
||||||
to_app(shell).watch(to_app(shell).WATCH_RAW); // raw
|
to_app(shell).watch(to_app(shell).WATCH_RAW); // raw
|
||||||
} else if (arguments[0] == (FL_(on)[0])) {
|
} else if (arguments[0] == (FL_(on)[0])) {
|
||||||
to_app(shell).watch(to_app(shell).WATCH_ON); // on
|
to_app(shell).watch(to_app(shell).WATCH_ON); // on
|
||||||
} else if (arguments[0] == (FL_(off)[0])) {
|
} else if (arguments[0] == (FL_(off)[0])) {
|
||||||
to_app(shell).watch(to_app(shell).WATCH_OFF); // off
|
to_app(shell).watch(to_app(shell).WATCH_OFF); // off
|
||||||
} else if (arguments[0] == (FL_(unknown)[0])) {
|
} else if (arguments[0] == (FL_(unknown)[0])) {
|
||||||
to_app(shell).watch(to_app(shell).WATCH_UNKNOWN); // unknown
|
to_app(shell).watch(to_app(shell).WATCH_UNKNOWN); // unknown
|
||||||
watch_id = WATCH_ID_NONE;
|
watch_id = WATCH_ID_NONE;
|
||||||
@@ -445,7 +447,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
|||||||
watch_id = Helpers::hextoint(arguments[0].c_str());
|
watch_id = Helpers::hextoint(arguments[0].c_str());
|
||||||
if (watch_id > 0
|
if (watch_id > 0
|
||||||
&& ((to_app(shell).watch() == to_app(shell).WATCH_OFF) || (to_app(shell).watch() == to_app(shell).WATCH_UNKNOWN))) {
|
&& ((to_app(shell).watch() == to_app(shell).WATCH_OFF) || (to_app(shell).watch() == to_app(shell).WATCH_UNKNOWN))) {
|
||||||
to_app(shell).watch(to_app(shell).WATCH_ON); // on
|
to_app(shell).watch(to_app(shell).WATCH_ON); // on
|
||||||
} else if (watch_id == 0) {
|
} else if (watch_id == 0) {
|
||||||
to_app(shell).watch(to_app(shell).WATCH_OFF); // off
|
to_app(shell).watch(to_app(shell).WATCH_OFF); // off
|
||||||
return;
|
return;
|
||||||
@@ -480,7 +482,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
|||||||
} else if (watch == to_app(shell).WATCH_RAW) {
|
} else if (watch == to_app(shell).WATCH_RAW) {
|
||||||
shell.printfln("Watching incoming telegrams, displayed as raw bytes"); // WATCH_RAW
|
shell.printfln("Watching incoming telegrams, displayed as raw bytes"); // WATCH_RAW
|
||||||
} else {
|
} else {
|
||||||
shell.printfln("Watching unknown telegrams"); // WATCH_UNKNOWN
|
shell.printfln("Watching unknown telegrams"); // WATCH_UNKNOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
watch_id = to_app(shell).watch_id();
|
watch_id = to_app(shell).watch_id();
|
||||||
@@ -623,7 +625,7 @@ void EMSESPShell::stopped() {
|
|||||||
void EMSESPShell::display_banner() {
|
void EMSESPShell::display_banner() {
|
||||||
println();
|
println();
|
||||||
printfln("┌────────────────────────────────────────┐");
|
printfln("┌────────────────────────────────────────┐");
|
||||||
printfln("│ %sEMS-ESP version %-12s%s │", COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_BOLD_OFF);
|
printfln("│ %sEMS-ESP version %-12s%s │", COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_BOLD_OFF);
|
||||||
printfln("│ %s%shttps://github.com/emsesp/EMS-ESP32%s │", COLOR_BRIGHT_GREEN, COLOR_UNDERLINE, COLOR_RESET);
|
printfln("│ %s%shttps://github.com/emsesp/EMS-ESP32%s │", COLOR_BRIGHT_GREEN, COLOR_UNDERLINE, COLOR_RESET);
|
||||||
printfln("│ │");
|
printfln("│ │");
|
||||||
printfln("│ type %shelp%s to show available commands │", COLOR_UNDERLINE, COLOR_RESET);
|
printfln("│ type %shelp%s to show available commands │", COLOR_UNDERLINE, COLOR_RESET);
|
||||||
|
|||||||
@@ -980,13 +980,13 @@ void Boiler::process_UBASettingsWW(std::shared_ptr<const Telegram> telegram) {
|
|||||||
// Boiler(0x08) -> Me(0x0B), UBAParameterWW(0x33), data: 08 FF 30 FB FF 28 FF 07 46 00 00
|
// Boiler(0x08) -> Me(0x0B), UBAParameterWW(0x33), data: 08 FF 30 FB FF 28 FF 07 46 00 00
|
||||||
void Boiler::process_UBAParameterWW(std::shared_ptr<const Telegram> telegram) {
|
void Boiler::process_UBAParameterWW(std::shared_ptr<const Telegram> telegram) {
|
||||||
// has_bitupdate(telegram, wwEquipt_,0,3); // 8=boiler has ww
|
// has_bitupdate(telegram, wwEquipt_,0,3); // 8=boiler has ww
|
||||||
has_update(telegram, wwActivated_, 1); // 0xFF means on
|
has_update(telegram, wwActivated_, 1); // 0xFF means on
|
||||||
has_update(telegram, wwSelTemp_, 2);
|
has_update(telegram, wwSelTemp_, 2);
|
||||||
has_update(telegram, wwHystOn_, 3); // Hyst on (default -5)
|
has_update(telegram, wwHystOn_, 3); // Hyst on (default -5)
|
||||||
has_update(telegram, wwHystOff_, 4); // Hyst off (default -1)
|
has_update(telegram, wwHystOff_, 4); // Hyst off (default -1)
|
||||||
has_update(telegram, wwFlowTempOffset_, 5); // default 40
|
has_update(telegram, wwFlowTempOffset_, 5); // default 40
|
||||||
has_update(telegram, wwCircPump_, 6); // 0xFF means on
|
has_update(telegram, wwCircPump_, 6); // 0xFF means on
|
||||||
has_update(telegram, wwCircMode_, 7); // 0=off, 1=1x3min 6=6x3min 7=continuous
|
has_update(telegram, wwCircMode_, 7); // 0=off, 1=1x3min 6=6x3min 7=continuous
|
||||||
has_update(telegram, wwDisinfectionTemp_, 8);
|
has_update(telegram, wwDisinfectionTemp_, 8);
|
||||||
has_bitupdate(telegram, wwChargeType_, 10, 0); // 0 = charge pump, 0xff = 3-way valve
|
has_bitupdate(telegram, wwChargeType_, 10, 0); // 0 = charge pump, 0xff = 3-way valve
|
||||||
|
|
||||||
@@ -1089,7 +1089,7 @@ void Boiler::process_UBAMonitorSlow(std::shared_ptr<const Telegram> telegram) {
|
|||||||
has_update(telegram, outdoorTemp_, 0);
|
has_update(telegram, outdoorTemp_, 0);
|
||||||
has_update(telegram, boilTemp_, 2);
|
has_update(telegram, boilTemp_, 2);
|
||||||
has_update(telegram, exhaustTemp_, 4);
|
has_update(telegram, exhaustTemp_, 4);
|
||||||
has_update(telegram, switchTemp_, 25); // only if there is a mixer module present
|
has_update(telegram, switchTemp_, 25); // only if there is a mixer module present
|
||||||
has_update(telegram, heatingPumpMod_, 9);
|
has_update(telegram, heatingPumpMod_, 9);
|
||||||
has_update(telegram, burnStarts_, 10, 3); // force to 3 bytes
|
has_update(telegram, burnStarts_, 10, 3); // force to 3 bytes
|
||||||
has_update(telegram, burnWorkMin_, 13, 3); // force to 3 bytes
|
has_update(telegram, burnWorkMin_, 13, 3); // force to 3 bytes
|
||||||
@@ -1414,7 +1414,7 @@ void Boiler::process_UBAErrorMessage(std::shared_ptr<const Telegram> telegram) {
|
|||||||
// data: displaycode(2), errornumber(2), year, month, hour, day, minute, duration(2), src-addr
|
// data: displaycode(2), errornumber(2), year, month, hour, day, minute, duration(2), src-addr
|
||||||
if (telegram->message_data[4] & 0x80) { // valid date
|
if (telegram->message_data[4] & 0x80) { // valid date
|
||||||
|
|
||||||
static uint32_t lastCodeDate_ = 0; // last code date
|
static uint32_t lastCodeDate_ = 0; // last code date
|
||||||
char code[3] = {0};
|
char code[3] = {0};
|
||||||
uint16_t codeNo = EMS_VALUE_SHORT_NOTSET;
|
uint16_t codeNo = EMS_VALUE_SHORT_NOTSET;
|
||||||
code[0] = telegram->message_data[0];
|
code[0] = telegram->message_data[0];
|
||||||
@@ -1530,12 +1530,12 @@ void Boiler::process_HpSilentMode(std::shared_ptr<const Telegram> telegram) {
|
|||||||
has_update(telegram, wwAltOpPrioWw_, 3); // range 30-120 minutes on Buderus WSW196i
|
has_update(telegram, wwAltOpPrioWw_, 3); // range 30-120 minutes on Buderus WSW196i
|
||||||
has_update(telegram, silentMode_, 10); // enum off-auto-on
|
has_update(telegram, silentMode_, 10); // enum off-auto-on
|
||||||
has_update(telegram, minTempSilent_, 11);
|
has_update(telegram, minTempSilent_, 11);
|
||||||
has_update(telegram, hpHystHeat_, 37); // is / 5
|
has_update(telegram, hpHystHeat_, 37); // is / 5
|
||||||
has_update(telegram, hpHystCool_, 35); // is / 5, maybe offset swapped with pool
|
has_update(telegram, hpHystCool_, 35); // is / 5, maybe offset swapped with pool
|
||||||
has_update(telegram, hpHystPool_, 33); // is / 5
|
has_update(telegram, hpHystPool_, 33); // is / 5
|
||||||
has_update(telegram, hpCircPumpWw_, 46);
|
has_update(telegram, hpCircPumpWw_, 46);
|
||||||
has_update(telegram, silentFrom_, 52); // in steps of 15 min
|
has_update(telegram, silentFrom_, 52); // in steps of 15 min
|
||||||
has_update(telegram, silentTo_, 53); // in steps of 15 min
|
has_update(telegram, silentTo_, 53); // in steps of 15 min
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boiler(0x08) -B-> All(0x00), ?(0x0488), data: 8E 00 00 00 00 00 01 03
|
// Boiler(0x08) -B-> All(0x00), ?(0x0488), data: 8E 00 00 00 00 00 01 03
|
||||||
@@ -1556,7 +1556,7 @@ void Boiler::process_HpAdditionalHeater(std::shared_ptr<const Telegram> telegram
|
|||||||
has_update(telegram, manDefrost_, 0); // off/on
|
has_update(telegram, manDefrost_, 0); // off/on
|
||||||
has_update(telegram, auxHeaterOnly_, 1);
|
has_update(telegram, auxHeaterOnly_, 1);
|
||||||
has_update(telegram, auxHeaterOff_, 2);
|
has_update(telegram, auxHeaterOff_, 2);
|
||||||
has_update(telegram, auxHeatMode_, 4); // eco/comfort
|
has_update(telegram, auxHeatMode_, 4); // eco/comfort
|
||||||
has_update(telegram, tempParMode_, 5);
|
has_update(telegram, tempParMode_, 5);
|
||||||
has_update(telegram, auxMaxLimit_, 14); // is * 10
|
has_update(telegram, auxMaxLimit_, 14); // is * 10
|
||||||
has_update(telegram, auxLimitStart_, 15); // is * 10
|
has_update(telegram, auxLimitStart_, 15); // is * 10
|
||||||
@@ -2131,6 +2131,7 @@ bool Boiler::set_tapwarmwater_activated(const char * value, const int8_t id) {
|
|||||||
wwTapActivated_ = 1;
|
wwTapActivated_ = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LOG_INFO("calling EMS_TYPE_UBAFunctionTest with %d", v);
|
||||||
write_command(EMS_TYPE_UBAFunctionTest, 0, message_data, sizeof(message_data), 0);
|
write_command(EMS_TYPE_UBAFunctionTest, 0, message_data, sizeof(message_data), 0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ void EMSESP::dump_all_values(uuid::console::Shell & shell) {
|
|||||||
if (device.product_id == 160) { // MM100
|
if (device.product_id == 160) { // MM100
|
||||||
device_id = 0x28; // wwc
|
device_id = 0x28; // wwc
|
||||||
} else {
|
} else {
|
||||||
device_id = 0x20; // hc
|
device_id = 0x20; // hc
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
device_id = 0x20; // should cover all the other device types
|
device_id = 0x20; // should cover all the other device types
|
||||||
@@ -926,7 +926,7 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
|
|||||||
if (telegram->type_id == publish_id_) {
|
if (telegram->type_id == publish_id_) {
|
||||||
publish_id_ = 0;
|
publish_id_ = 0;
|
||||||
}
|
}
|
||||||
emsdevice->has_update(false); // reset flag
|
emsdevice->has_update(false); // reset flag
|
||||||
if (!Mqtt::publish_single()) {
|
if (!Mqtt::publish_single()) {
|
||||||
publish_device_values(emsdevice->device_type()); // publish to MQTT if we explicitly have too
|
publish_device_values(emsdevice->device_type()); // publish to MQTT if we explicitly have too
|
||||||
}
|
}
|
||||||
@@ -1118,7 +1118,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const
|
|||||||
name = "Modem";
|
name = "Modem";
|
||||||
device_type = DeviceType::CONNECT;
|
device_type = DeviceType::CONNECT;
|
||||||
} else if (device_id == EMSdevice::EMS_DEVICE_ID_CONVERTER) {
|
} else if (device_id == EMSdevice::EMS_DEVICE_ID_CONVERTER) {
|
||||||
name = "Converter"; // generic
|
name = "Converter"; // generic
|
||||||
} else if (device_id == EMSdevice::EMS_DEVICE_ID_CLOCK) {
|
} else if (device_id == EMSdevice::EMS_DEVICE_ID_CLOCK) {
|
||||||
name = "Clock"; // generic
|
name = "Clock"; // generic
|
||||||
device_type = DeviceType::CONTROLLER;
|
device_type = DeviceType::CONTROLLER;
|
||||||
@@ -1390,7 +1390,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) {
|
|||||||
#endif
|
#endif
|
||||||
Roomctrl::check((data[1] ^ 0x80 ^ rxservice_.ems_mask()), data); // check if there is a message for the roomcontroller
|
Roomctrl::check((data[1] ^ 0x80 ^ rxservice_.ems_mask()), data); // check if there is a message for the roomcontroller
|
||||||
|
|
||||||
rxservice_.add(data, length); // add to RxQueue
|
rxservice_.add(data, length); // add to RxQueue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1470,8 +1470,8 @@ void EMSESP::start() {
|
|||||||
bool factory_settings = false;
|
bool factory_settings = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
esp8266React.begin(); // loads core system services settings (network, mqtt, ap, ntp etc)
|
esp8266React.begin(); // loads core system services settings (network, mqtt, ap, ntp etc)
|
||||||
webLogService.begin(); // start web log service. now we can start capturing logs to the web log
|
webLogService.begin(); // start web log service. now we can start capturing logs to the web log
|
||||||
|
|
||||||
LOG_INFO("Starting EMS-ESP version %s", EMSESP_APP_VERSION); // welcome message
|
LOG_INFO("Starting EMS-ESP version %s", EMSESP_APP_VERSION); // welcome message
|
||||||
LOG_DEBUG("System is running in Debug mode");
|
LOG_DEBUG("System is running in Debug mode");
|
||||||
@@ -1491,7 +1491,7 @@ void EMSESP::start() {
|
|||||||
system_.system_restart();
|
system_.system_restart();
|
||||||
};
|
};
|
||||||
|
|
||||||
system_.reload_settings(); // ... and store some of the settings locally
|
system_.reload_settings(); // ... and store some of the settings locally
|
||||||
|
|
||||||
webCustomizationService.begin(); // load the customizations
|
webCustomizationService.begin(); // load the customizations
|
||||||
webSchedulerService.begin(); // load the scheduler events
|
webSchedulerService.begin(); // load the scheduler events
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ MAKE_WORD(info)
|
|||||||
MAKE_WORD(settings)
|
MAKE_WORD(settings)
|
||||||
MAKE_WORD(value)
|
MAKE_WORD(value)
|
||||||
MAKE_WORD(entities)
|
MAKE_WORD(entities)
|
||||||
|
MAKE_WORD(coldshot)
|
||||||
|
|
||||||
// device types - lowercase, used in MQTT
|
// device types - lowercase, used in MQTT
|
||||||
MAKE_WORD(boiler)
|
MAKE_WORD(boiler)
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ MAKE_WORD_TRANSLATION(system_info_cmd, "show system status", "Zeige System-Statu
|
|||||||
MAKE_WORD_TRANSLATION(schedule_cmd, "enable schedule item", "Aktiviere Zeitplan", "activeer tijdschema item", "", "aktywuj wybrany harmonogram", "", "", "program öğesini etkinleştir", "abilitare l'elemento programmato") // TODO translate
|
MAKE_WORD_TRANSLATION(schedule_cmd, "enable schedule item", "Aktiviere Zeitplan", "activeer tijdschema item", "", "aktywuj wybrany harmonogram", "", "", "program öğesini etkinleştir", "abilitare l'elemento programmato") // TODO translate
|
||||||
MAKE_WORD_TRANSLATION(entity_cmd, "set custom value on ems", "Sende eigene Entitäten zu EMS", "verstuur custom waarde naar EMS", "", "wyślij własną wartość na EMS", "", "", "", "imposta valori personalizzati su EMS") // TODO translate
|
MAKE_WORD_TRANSLATION(entity_cmd, "set custom value on ems", "Sende eigene Entitäten zu EMS", "verstuur custom waarde naar EMS", "", "wyślij własną wartość na EMS", "", "", "", "imposta valori personalizzati su EMS") // TODO translate
|
||||||
MAKE_WORD_TRANSLATION(commands_response, "get response", "Hole Antwort", "Verzoek om antwoord", "", "", "", "", "") // TODO translate
|
MAKE_WORD_TRANSLATION(commands_response, "get response", "Hole Antwort", "Verzoek om antwoord", "", "", "", "", "") // TODO translate
|
||||||
|
MAKE_WORD_TRANSLATION(coldshot_cmd, "send a cold shot of water", "", "", "", "", "", "", "", "") // TODO translate
|
||||||
|
|
||||||
// tags
|
// tags
|
||||||
MAKE_WORD_TRANSLATION(tag_boiler_data_ww, "dhw", "WW", "dhw", "VV", "CWU", "dhw", "ecs", "SKS", "dhw")
|
MAKE_WORD_TRANSLATION(tag_boiler_data_ww, "dhw", "WW", "dhw", "VV", "CWU", "dhw", "ecs", "SKS", "dhw")
|
||||||
|
|||||||
24
src/mqtt.cpp
24
src/mqtt.cpp
@@ -278,9 +278,13 @@ void Mqtt::on_message(const char * topic, const uint8_t * payload, size_t len) c
|
|||||||
if (return_code != CommandRet::OK) {
|
if (return_code != CommandRet::OK) {
|
||||||
char error[100];
|
char error[100];
|
||||||
if (output.size()) {
|
if (output.size()) {
|
||||||
snprintf(error, sizeof(error), "Call failed with error: %s (%s)", (const char *)output["message"], Command::return_code_string(return_code).c_str());
|
snprintf(error,
|
||||||
|
sizeof(error),
|
||||||
|
"MQTT command failed with error: %s (%s)",
|
||||||
|
(const char *)output["message"],
|
||||||
|
Command::return_code_string(return_code).c_str());
|
||||||
} else {
|
} else {
|
||||||
snprintf(error, sizeof(error), "Call failed with error code (%s)", Command::return_code_string(return_code).c_str());
|
snprintf(error, sizeof(error), "MQTT command failed with error code (%s)", Command::return_code_string(return_code).c_str());
|
||||||
}
|
}
|
||||||
LOG_ERROR(error);
|
LOG_ERROR(error);
|
||||||
Mqtt::queue_publish("response", error);
|
Mqtt::queue_publish("response", error);
|
||||||
@@ -506,7 +510,7 @@ void Mqtt::on_connect() {
|
|||||||
// publish to the last will topic (see Mqtt::start() function) to say we're alive
|
// publish to the last will topic (see Mqtt::start() function) to say we're alive
|
||||||
queue_publish_retain("status", "online", true); // with retain on
|
queue_publish_retain("status", "online", true); // with retain on
|
||||||
|
|
||||||
mqtt_publish_fails_ = 0; // reset fail count to 0
|
mqtt_publish_fails_ = 0; // reset fail count to 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Home Assistant Discovery - the main master Device called EMS-ESP
|
// Home Assistant Discovery - the main master Device called EMS-ESP
|
||||||
@@ -679,7 +683,7 @@ bool Mqtt::queue_remove_topic(const char * topic) {
|
|||||||
if (ha_enabled_) {
|
if (ha_enabled_) {
|
||||||
return queue_publish_message(Mqtt::discovery_prefix() + topic, "", true); // publish with retain to remove from broker
|
return queue_publish_message(Mqtt::discovery_prefix() + topic, "", true); // publish with retain to remove from broker
|
||||||
} else {
|
} else {
|
||||||
return queue_publish_message(topic, "", true); // publish with retain to remove from broker
|
return queue_publish_message(topic, "", true); // publish with retain to remove from broker
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -691,7 +695,7 @@ bool Mqtt::queue_ha(const char * topic, const JsonObject & payload) {
|
|||||||
|
|
||||||
std::string payload_text;
|
std::string payload_text;
|
||||||
payload_text.reserve(measureJson(payload) + 1);
|
payload_text.reserve(measureJson(payload) + 1);
|
||||||
serializeJson(payload, payload_text); // convert json to string
|
serializeJson(payload, payload_text); // convert json to string
|
||||||
|
|
||||||
return queue_publish_message(Mqtt::discovery_prefix() + topic, payload_text, true); // with retain true
|
return queue_publish_message(Mqtt::discovery_prefix() + topic, payload_text, true); // with retain true
|
||||||
}
|
}
|
||||||
@@ -860,7 +864,7 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
|||||||
if (type == DeviceValueType::BOOL) {
|
if (type == DeviceValueType::BOOL) {
|
||||||
snprintf(topic, sizeof(topic), "binary_sensor/%s", config_topic); // binary sensor (for booleans)
|
snprintf(topic, sizeof(topic), "binary_sensor/%s", config_topic); // binary sensor (for booleans)
|
||||||
} else {
|
} else {
|
||||||
snprintf(topic, sizeof(topic), "sensor/%s", config_topic); // normal HA sensor
|
snprintf(topic, sizeof(topic), "sensor/%s", config_topic); // normal HA sensor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -874,13 +878,13 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
|||||||
// build the payload
|
// build the payload
|
||||||
StaticJsonDocument<EMSESP_JSON_SIZE_LARGE> doc;
|
StaticJsonDocument<EMSESP_JSON_SIZE_LARGE> doc;
|
||||||
doc["uniq_id"] = uniq_id;
|
doc["uniq_id"] = uniq_id;
|
||||||
doc["obj_id"] = uniq_id; // same as unique_id
|
doc["obj_id"] = uniq_id; // same as unique_id
|
||||||
|
|
||||||
const char * ic_ha = "ic"; // icon - only set this if there is no device class
|
const char * ic_ha = "ic"; // icon - only set this if there is no device class
|
||||||
const char * sc_ha = "stat_cla"; // state class
|
const char * sc_ha = "stat_cla"; // state class
|
||||||
const char * uom_ha = "unit_of_meas"; // unit of measure
|
const char * uom_ha = "unit_of_meas"; // unit of measure
|
||||||
|
|
||||||
char sample_val[30] = "0"; // sample, correct(!) entity value, used only to prevent warning/error in HA if real value is not published yet
|
char sample_val[30] = "0"; // sample, correct(!) entity value, used only to prevent warning/error in HA if real value is not published yet
|
||||||
|
|
||||||
// handle commands, which are device entities that are writable
|
// handle commands, which are device entities that are writable
|
||||||
// we add the command topic parameter
|
// we add the command topic parameter
|
||||||
@@ -952,7 +956,7 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
|||||||
} else {
|
} else {
|
||||||
snprintf(ha_name, sizeof(ha_name), "%s", F_name); // no tag
|
snprintf(ha_name, sizeof(ha_name), "%s", F_name); // no tag
|
||||||
}
|
}
|
||||||
free(F_name); // very important!
|
free(F_name); // very important!
|
||||||
doc["name"] = ha_name;
|
doc["name"] = ha_name;
|
||||||
|
|
||||||
// value template
|
// value template
|
||||||
@@ -1164,7 +1168,7 @@ bool Mqtt::publish_ha_climate_config(const uint8_t tag, const bool has_roomtemp,
|
|||||||
if (Mqtt::entity_format() == entityFormat::MULTI_SHORT) {
|
if (Mqtt::entity_format() == entityFormat::MULTI_SHORT) {
|
||||||
snprintf(uniq_id_s, sizeof(uniq_id_s), "%s_thermostat_hc%d", mqtt_basename_.c_str(), hc_num); // add basename
|
snprintf(uniq_id_s, sizeof(uniq_id_s), "%s_thermostat_hc%d", mqtt_basename_.c_str(), hc_num); // add basename
|
||||||
} else {
|
} else {
|
||||||
snprintf(uniq_id_s, sizeof(uniq_id_s), "thermostat_hc%d", hc_num); // backward compatible with v3.4
|
snprintf(uniq_id_s, sizeof(uniq_id_s), "thermostat_hc%d", hc_num); // backward compatible with v3.4
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(temp_cmd_s, sizeof(temp_cmd_s), "~/thermostat/hc%d/seltemp", hc_num);
|
snprintf(temp_cmd_s, sizeof(temp_cmd_s), "~/thermostat/hc%d/seltemp", hc_num);
|
||||||
|
|||||||
103
src/shower.cpp
103
src/shower.cpp
@@ -22,6 +22,8 @@ namespace emsesp {
|
|||||||
|
|
||||||
uuid::log::Logger Shower::logger_{F_(shower), uuid::log::Facility::CONSOLE};
|
uuid::log::Logger Shower::logger_{F_(shower), uuid::log::Facility::CONSOLE};
|
||||||
|
|
||||||
|
static bool force_coldshot = false;
|
||||||
|
|
||||||
void Shower::start() {
|
void Shower::start() {
|
||||||
EMSESP::webSettingsService.read([&](WebSettings & settings) {
|
EMSESP::webSettingsService.read([&](WebSettings & settings) {
|
||||||
shower_timer_ = settings.shower_timer;
|
shower_timer_ = settings.shower_timer;
|
||||||
@@ -30,7 +32,27 @@ void Shower::start() {
|
|||||||
shower_alert_coldshot_ = settings.shower_alert_coldshot * 1000; // convert from seconds
|
shower_alert_coldshot_ = settings.shower_alert_coldshot * 1000; // convert from seconds
|
||||||
});
|
});
|
||||||
|
|
||||||
set_shower_state(false, true); // turns shower to off and creates HA topic if not already done
|
Command::add(
|
||||||
|
EMSdevice::DeviceType::BOILER,
|
||||||
|
F_(coldshot),
|
||||||
|
[&](const char * value, const int8_t id, JsonObject & output) {
|
||||||
|
LOG_INFO("Forcing coldshot...");
|
||||||
|
if (shower_state_) {
|
||||||
|
output["message"] = "OK";
|
||||||
|
force_coldshot = true;
|
||||||
|
} else {
|
||||||
|
output["message"] = "Coldshot failed. Shower not active";
|
||||||
|
LOG_WARNING("Coldshot failed. Shower not active");
|
||||||
|
force_coldshot = false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
FL_(coldshot_cmd),
|
||||||
|
CommandFlag::ADMIN_ONLY);
|
||||||
|
|
||||||
|
if (shower_timer_) {
|
||||||
|
set_shower_state(false, true); // turns shower to off and creates HA topic if not already done
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shower::loop() {
|
void Shower::loop() {
|
||||||
@@ -57,10 +79,10 @@ void Shower::loop() {
|
|||||||
// first check to see if hot water has been on long enough to be recognized as a Shower/Bath
|
// first check to see if hot water has been on long enough to be recognized as a Shower/Bath
|
||||||
if (!shower_state_ && (time_now - timer_start_) > SHOWER_MIN_DURATION) {
|
if (!shower_state_ && (time_now - timer_start_) > SHOWER_MIN_DURATION) {
|
||||||
set_shower_state(true);
|
set_shower_state(true);
|
||||||
LOG_DEBUG("[Shower] hot water still running, starting shower timer");
|
LOG_DEBUG("hot water still running, starting shower timer");
|
||||||
}
|
}
|
||||||
// check if the shower has been on too long
|
// check if the shower has been on too long
|
||||||
else if ((time_now - timer_start_) > shower_alert_trigger_) {
|
else if ((shower_alert_ && ((time_now - timer_start_) > shower_alert_trigger_)) || force_coldshot) {
|
||||||
shower_alert_start();
|
shower_alert_start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,11 +101,11 @@ void Shower::loop() {
|
|||||||
if (duration_ > SHOWER_MIN_DURATION) {
|
if (duration_ > SHOWER_MIN_DURATION) {
|
||||||
StaticJsonDocument<EMSESP_JSON_SIZE_SMALL> doc;
|
StaticJsonDocument<EMSESP_JSON_SIZE_SMALL> doc;
|
||||||
|
|
||||||
char s[50];
|
// char s[50];
|
||||||
snprintf(s, 50, "%d minutes and %d seconds", (uint8_t)(duration_ / 60000), (uint8_t)((duration_ / 1000) % 60));
|
// snprintf(s, 50, "%02u:%02u:%02u", (uint8_t)(duration_ / 3600000UL), (uint8_t)(duration_ / 60000UL), (uint8_t)((duration_ / 1000UL) % 60));
|
||||||
doc["duration"] = s;
|
doc["duration"] = (uint8_t)(duration_ / 1000UL); // seconds
|
||||||
Mqtt::queue_publish("shower_data", doc.as<JsonObject>());
|
Mqtt::queue_publish("shower_data", doc.as<JsonObject>());
|
||||||
LOG_DEBUG("[Shower] finished with duration %d", duration_);
|
LOG_INFO("finished with duration %d", duration_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,21 +128,22 @@ void Shower::loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// turn off hot water to send a shot of cold
|
||||||
|
void Shower::shower_alert_start() {
|
||||||
|
LOG_DEBUG("Shower Alert started");
|
||||||
|
(void)Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "false");
|
||||||
|
doing_cold_shot_ = true;
|
||||||
|
force_coldshot = false;
|
||||||
|
alert_timer_start_ = uuid::get_uptime(); // timer starts now
|
||||||
|
}
|
||||||
|
|
||||||
// turn back on the hot water for the shower
|
// turn back on the hot water for the shower
|
||||||
void Shower::shower_alert_stop() {
|
void Shower::shower_alert_stop() {
|
||||||
if (doing_cold_shot_) {
|
if (doing_cold_shot_) {
|
||||||
LOG_DEBUG("Shower Alert stopped");
|
LOG_DEBUG("Shower Alert stopped");
|
||||||
(void)Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "true");
|
(void)Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "true");
|
||||||
doing_cold_shot_ = false;
|
doing_cold_shot_ = false;
|
||||||
}
|
force_coldshot = false;
|
||||||
}
|
|
||||||
// turn off hot water to send a shot of cold
|
|
||||||
void Shower::shower_alert_start() {
|
|
||||||
if (shower_alert_) {
|
|
||||||
LOG_DEBUG("Shower Alert started");
|
|
||||||
(void)Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "false");
|
|
||||||
doing_cold_shot_ = true;
|
|
||||||
alert_timer_start_ = uuid::get_uptime(); // timer starts now
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,15 +151,11 @@ void Shower::shower_alert_start() {
|
|||||||
// and creates the HA config topic if HA enabled
|
// and creates the HA config topic if HA enabled
|
||||||
// force is used by EMSESP::publish_all_loop()
|
// force is used by EMSESP::publish_all_loop()
|
||||||
void Shower::set_shower_state(bool state, bool force) {
|
void Shower::set_shower_state(bool state, bool force) {
|
||||||
if (!shower_timer_ && !shower_alert_) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// sets the state
|
// sets the state
|
||||||
shower_state_ = state;
|
shower_state_ = state;
|
||||||
|
|
||||||
// only publish if that state has changed
|
// only publish if that state has changed
|
||||||
static bool old_shower_state_;
|
static bool old_shower_state_ = false;
|
||||||
if ((shower_state_ == old_shower_state_) && !force) {
|
if ((shower_state_ == old_shower_state_) && !force) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -149,10 +168,15 @@ void Shower::set_shower_state(bool state, bool force) {
|
|||||||
// send out HA MQTT Discovery config topic
|
// send out HA MQTT Discovery config topic
|
||||||
if ((Mqtt::ha_enabled()) && (!ha_configdone_ || force)) {
|
if ((Mqtt::ha_enabled()) && (!ha_configdone_ || force)) {
|
||||||
StaticJsonDocument<EMSESP_JSON_SIZE_LARGE> doc;
|
StaticJsonDocument<EMSESP_JSON_SIZE_LARGE> doc;
|
||||||
|
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||||
|
char str[70];
|
||||||
|
char stat_t[50];
|
||||||
|
|
||||||
|
//
|
||||||
|
// shower_active topic
|
||||||
|
//
|
||||||
doc["name"] = "Shower Active";
|
doc["name"] = "Shower Active";
|
||||||
|
|
||||||
char str[70];
|
|
||||||
if (Mqtt::entity_format() == Mqtt::entityFormat::MULTI_SHORT) {
|
if (Mqtt::entity_format() == Mqtt::entityFormat::MULTI_SHORT) {
|
||||||
snprintf(str, sizeof(str), "%s_shower_active", Mqtt::basename().c_str());
|
snprintf(str, sizeof(str), "%s_shower_active", Mqtt::basename().c_str());
|
||||||
} else {
|
} else {
|
||||||
@@ -161,7 +185,6 @@ void Shower::set_shower_state(bool state, bool force) {
|
|||||||
doc["uniq_id"] = str;
|
doc["uniq_id"] = str;
|
||||||
doc["object_id"] = str;
|
doc["object_id"] = str;
|
||||||
|
|
||||||
char stat_t[50];
|
|
||||||
snprintf(stat_t, sizeof(stat_t), "%s/shower_active", Mqtt::basename().c_str());
|
snprintf(stat_t, sizeof(stat_t), "%s/shower_active", Mqtt::basename().c_str());
|
||||||
doc["stat_t"] = stat_t;
|
doc["stat_t"] = stat_t;
|
||||||
|
|
||||||
@@ -181,13 +204,39 @@ void Shower::set_shower_state(bool state, bool force) {
|
|||||||
JsonArray ids = dev.createNestedArray("ids");
|
JsonArray ids = dev.createNestedArray("ids");
|
||||||
ids.add(Mqtt::basename());
|
ids.add(Mqtt::basename());
|
||||||
|
|
||||||
// add "availability" section
|
Mqtt::add_avty_to_doc(stat_t, doc.as<JsonObject>()); // add "availability" section
|
||||||
Mqtt::add_avty_to_doc(stat_t, doc.as<JsonObject>());
|
|
||||||
|
|
||||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
|
||||||
snprintf(topic, sizeof(topic), "binary_sensor/%s/shower_active/config", Mqtt::basename().c_str());
|
snprintf(topic, sizeof(topic), "binary_sensor/%s/shower_active/config", Mqtt::basename().c_str());
|
||||||
|
|
||||||
ha_configdone_ = Mqtt::queue_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
ha_configdone_ = Mqtt::queue_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
||||||
|
|
||||||
|
//
|
||||||
|
// shower_duaration topic
|
||||||
|
//
|
||||||
|
doc.clear();
|
||||||
|
|
||||||
|
snprintf(str, sizeof(str), "%s_shower_duration", Mqtt::basename().c_str());
|
||||||
|
|
||||||
|
doc["uniq_id"] = str;
|
||||||
|
doc["object_id"] = str;
|
||||||
|
|
||||||
|
snprintf(stat_t, sizeof(stat_t), "%s/shower_data", Mqtt::basename().c_str());
|
||||||
|
doc["stat_t"] = stat_t;
|
||||||
|
|
||||||
|
doc["name"] = "Shower Duration";
|
||||||
|
doc["val_tpl"] = "{{value_json.duration if value_json.duration is defined else 0}}";
|
||||||
|
doc["unit_of_meas"] = "s";
|
||||||
|
doc["stat_cla"] = "measurement";
|
||||||
|
doc["dev_cla"] = "duration";
|
||||||
|
doc["ent_cat"] = "diagnostic";
|
||||||
|
|
||||||
|
JsonObject dev2 = doc.createNestedObject("dev");
|
||||||
|
JsonArray ids2 = dev2.createNestedArray("ids");
|
||||||
|
ids2.add(Mqtt::basename());
|
||||||
|
|
||||||
|
Mqtt::add_avty_to_doc(stat_t, doc.as<JsonObject>(), "value_json.duration is defined"); // add "availability" section
|
||||||
|
|
||||||
|
snprintf(topic, sizeof(topic), "sensor/%s/shower_duration/config", Mqtt::basename().c_str());
|
||||||
|
Mqtt::queue_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ class Shower {
|
|||||||
|
|
||||||
void set_shower_state(bool state, bool force = false);
|
void set_shower_state(bool state, bool force = false);
|
||||||
|
|
||||||
|
// commands
|
||||||
|
static bool command_coldshot(const char * value, const int8_t id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static uuid::log::Logger logger_;
|
static uuid::log::Logger logger_;
|
||||||
|
|
||||||
@@ -46,9 +49,9 @@ class Shower {
|
|||||||
uint32_t shower_alert_coldshot_; // default 10 seconds for cold water before turning back hot water
|
uint32_t shower_alert_coldshot_; // default 10 seconds for cold water before turning back hot water
|
||||||
bool ha_configdone_ = false; // for HA MQTT Discovery
|
bool ha_configdone_ = false; // for HA MQTT Discovery
|
||||||
bool shower_state_;
|
bool shower_state_;
|
||||||
uint32_t timer_start_; // ms
|
uint32_t timer_start_; // ms
|
||||||
uint32_t timer_pause_; // ms
|
uint32_t timer_pause_; // ms
|
||||||
uint32_t duration_; // ms
|
uint32_t duration_; // ms
|
||||||
|
|
||||||
// cold shot
|
// cold shot
|
||||||
uint32_t alert_timer_start_; // ms
|
uint32_t alert_timer_start_; // ms
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
shell.printfln("Testing adding a general boiler & thermostat...");
|
shell.printfln("Testing adding a general boiler & thermostat...");
|
||||||
run_test("general");
|
run_test("general");
|
||||||
// shell.invoke_command("show devices");
|
// shell.invoke_command("show devices");
|
||||||
// shell.invoke_command("show values");
|
shell.invoke_command("show values");
|
||||||
shell.invoke_command("call system publish");
|
shell.invoke_command("call system publish");
|
||||||
// shell.invoke_command("show mqtt");
|
// shell.invoke_command("show mqtt");
|
||||||
ok = true;
|
ok = true;
|
||||||
@@ -280,6 +280,21 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
ok = true;
|
ok = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (command == "coldshot") {
|
||||||
|
shell.printfln("Testing coldshot...");
|
||||||
|
run_test("general");
|
||||||
|
|
||||||
|
#ifdef EMSESP_STANDALONE
|
||||||
|
AsyncWebServerRequest request;
|
||||||
|
request.method(HTTP_GET);
|
||||||
|
request.url("/api/boiler/coldshot");
|
||||||
|
EMSESP::webAPIService.webAPIService_get(&request);
|
||||||
|
#else
|
||||||
|
shell.invoke_command("call boiler coldshot");
|
||||||
|
#endif
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (command == "string2minutes") {
|
if (command == "string2minutes") {
|
||||||
shell.printfln("Testing string2minutes()...");
|
shell.printfln("Testing string2minutes()...");
|
||||||
std::string time_s = "12:00";
|
std::string time_s = "12:00";
|
||||||
@@ -1005,10 +1020,10 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
EMSESP::mqtt_.incoming("ems-esp/thermostat_hc1", "22"); // HA only
|
EMSESP::mqtt_.incoming("ems-esp/thermostat_hc1", "22"); // HA only
|
||||||
EMSESP::mqtt_.incoming("ems-esp/thermostat_hc1", "off"); // HA only
|
EMSESP::mqtt_.incoming("ems-esp/thermostat_hc1", "off"); // HA only
|
||||||
EMSESP::mqtt_.incoming("ems-esp/system/send", "11 12 13");
|
EMSESP::mqtt_.incoming("ems-esp/system/send", "11 12 13");
|
||||||
EMSESP::mqtt_.incoming("ems-esp/boiler/syspress"); // empty payload
|
EMSESP::mqtt_.incoming("ems-esp/boiler/syspress"); // empty payload
|
||||||
EMSESP::mqtt_.incoming("ems-esp/thermostat/mode"); // empty payload
|
EMSESP::mqtt_.incoming("ems-esp/thermostat/mode"); // empty payload
|
||||||
EMSESP::mqtt_.incoming("ems-esp/system/publish");
|
EMSESP::mqtt_.incoming("ems-esp/system/publish");
|
||||||
EMSESP::mqtt_.incoming("ems-esp/thermostat/seltemp"); // empty payload
|
EMSESP::mqtt_.incoming("ems-esp/thermostat/seltemp"); // empty payload
|
||||||
|
|
||||||
EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp", "59");
|
EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp", "59");
|
||||||
EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp");
|
EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp");
|
||||||
@@ -1204,7 +1219,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
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
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
shell.invoke_command("show");
|
shell.invoke_command("show");
|
||||||
ok = true;
|
ok = true;
|
||||||
@@ -1446,7 +1461,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
shell.invoke_command("call");
|
shell.invoke_command("call");
|
||||||
shell.invoke_command("call system info");
|
shell.invoke_command("call system info");
|
||||||
|
|
||||||
EMSESP::mqtt_.incoming("ems-esp/system", "{\"cmd\":\"info\"}"); // this should fail
|
EMSESP::mqtt_.incoming("ems-esp/system", "{\"cmd\":\"info\"}"); // this should fail
|
||||||
|
|
||||||
EMSESP::mqtt_.incoming("ems-esp/thermostat", "{\"cmd\":\"temp\",\"data\":23.45}"); // this should work just fine
|
EMSESP::mqtt_.incoming("ems-esp/thermostat", "{\"cmd\":\"temp\",\"data\":23.45}"); // this should work just fine
|
||||||
EMSESP::mqtt_.incoming("ems-esp/thermostat", "{\"cmd\":\"TeMP\",\"data\":23.45}"); // test mix cased cmd
|
EMSESP::mqtt_.incoming("ems-esp/thermostat", "{\"cmd\":\"TeMP\",\"data\":23.45}"); // test mix cased cmd
|
||||||
@@ -1559,7 +1574,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
// EMSESP::mqtt_.incoming(system_topic, "{\"cmd\":\"pin\",\"id\":12,\"data\":\"1\"}");
|
// EMSESP::mqtt_.incoming(system_topic, "{\"cmd\":\"pin\",\"id\":12,\"data\":\"1\"}");
|
||||||
|
|
||||||
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"wwmode\",\"data\":\"auto\"}");
|
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"wwmode\",\"data\":\"auto\"}");
|
||||||
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"mode\",\"data\":\"typo\",\"id\":2}"); // invalid mode
|
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"mode\",\"data\":\"typo\",\"id\":2}"); // invalid mode
|
||||||
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"mode\",\"data\":\"auto\",\"id\":2}");
|
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"mode\",\"data\":\"auto\",\"id\":2}");
|
||||||
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"mode\",\"data\":\"auto\",\"hc\":2}"); // hc as number
|
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"mode\",\"data\":\"auto\",\"hc\":2}"); // hc as number
|
||||||
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"seltemp\",\"data\":19.5,\"hc\":1}"); // data as number
|
EMSESP::mqtt_.incoming(thermostat_topic, "{\"cmd\":\"seltemp\",\"data\":19.5,\"hc\":1}"); // data as number
|
||||||
|
|||||||
@@ -26,11 +26,12 @@
|
|||||||
|
|
||||||
namespace emsesp {
|
namespace emsesp {
|
||||||
|
|
||||||
|
// #define EMSESP_DEBUG_DEFAULT "general"
|
||||||
|
|
||||||
// #define EMSESP_DEBUG_DEFAULT "thermostat"
|
// #define EMSESP_DEBUG_DEFAULT "thermostat"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "solar"
|
// #define EMSESP_DEBUG_DEFAULT "solar"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "web"
|
// #define EMSESP_DEBUG_DEFAULT "web"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "mqtt"
|
// #define EMSESP_DEBUG_DEFAULT "mqtt"
|
||||||
#define EMSESP_DEBUG_DEFAULT "general"
|
|
||||||
// #define EMSESP_DEBUG_DEFAULT "boiler"
|
// #define EMSESP_DEBUG_DEFAULT "boiler"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "mqtt2"
|
// #define EMSESP_DEBUG_DEFAULT "mqtt2"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "mqtt_nested"
|
// #define EMSESP_DEBUG_DEFAULT "mqtt_nested"
|
||||||
@@ -53,6 +54,7 @@ namespace emsesp {
|
|||||||
// #define EMSESP_DEBUG_DEFAULT "custom"
|
// #define EMSESP_DEBUG_DEFAULT "custom"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "entity_dump"
|
// #define EMSESP_DEBUG_DEFAULT "entity_dump"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "memory"
|
// #define EMSESP_DEBUG_DEFAULT "memory"
|
||||||
|
#define EMSESP_DEBUG_DEFAULT "coldshot"
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.7.0-dev.0"
|
#define EMSESP_APP_VERSION "3.7.0-dev.1"
|
||||||
|
|||||||
@@ -121,9 +121,9 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) {
|
|||||||
if (return_code != CommandRet::OK) {
|
if (return_code != CommandRet::OK) {
|
||||||
char error[100];
|
char error[100];
|
||||||
if (output.size()) {
|
if (output.size()) {
|
||||||
snprintf(error, sizeof(error), "Call failed with error: %s (%s)", (const char *)output["message"], Command::return_code_string(return_code).c_str());
|
snprintf(error, sizeof(error), "API failed with error: %s (%s)", (const char *)output["message"], Command::return_code_string(return_code).c_str());
|
||||||
} else {
|
} else {
|
||||||
snprintf(error, sizeof(error), "Call failed with error code (%s)", Command::return_code_string(return_code).c_str());
|
snprintf(error, sizeof(error), "API failed with error code (%s)", Command::return_code_string(return_code).c_str());
|
||||||
}
|
}
|
||||||
emsesp::EMSESP::logger().err(error);
|
emsesp::EMSESP::logger().err(error);
|
||||||
api_fails_++;
|
api_fails_++;
|
||||||
|
|||||||
@@ -219,8 +219,8 @@ bool WebEntityService::get_value_info(JsonObject & output, const char * cmd) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Helpers::toLower(cmd) == "commands") {
|
if (Helpers::toLower(cmd) == "commands") {
|
||||||
output["info"] = "lists all values";
|
output["info"] = "list all values";
|
||||||
output["commands"] = "lists all commands";
|
output["commands"] = "list all commands";
|
||||||
for (const auto & entity : *entityItems) {
|
for (const auto & entity : *entityItems) {
|
||||||
output[entity.name] = "custom entitiy";
|
output[entity.name] = "custom entitiy";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user