mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
@@ -31,7 +31,7 @@
|
||||
"async-validator": "^4.2.5",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"mime-types": "^2.1.35",
|
||||
"preact": "^10.23.2",
|
||||
"preact": "^10.24.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-icons": "^5.3.0",
|
||||
@@ -44,10 +44,10 @@
|
||||
"@babel/core": "^7.25.2",
|
||||
"@eslint/js": "^9.10.0",
|
||||
"@preact/compat": "^18.3.1",
|
||||
"@preact/preset-vite": "^2.9.0",
|
||||
"@preact/preset-vite": "^2.9.1",
|
||||
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
||||
"@types/formidable": "^3",
|
||||
"@types/node": "^22.5.4",
|
||||
"@types/node": "^22.5.5",
|
||||
"@types/react": "^18.3.5",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
@@ -59,9 +59,9 @@
|
||||
"rollup-plugin-visualizer": "^5.12.0",
|
||||
"terser": "^5.32.0",
|
||||
"typescript-eslint": "8.5.0",
|
||||
"vite": "^5.4.4",
|
||||
"vite": "^5.4.5",
|
||||
"vite-plugin-imagemin": "^0.6.1",
|
||||
"vite-tsconfig-paths": "^5.0.1"
|
||||
},
|
||||
"packageManager": "yarn@4.4.1"
|
||||
"packageManager": "yarn@4.5.0"
|
||||
}
|
||||
|
||||
@@ -1054,9 +1054,9 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@preact/preset-vite@npm:^2.9.0":
|
||||
version: 2.9.0
|
||||
resolution: "@preact/preset-vite@npm:2.9.0"
|
||||
"@preact/preset-vite@npm:^2.9.1":
|
||||
version: 2.9.1
|
||||
resolution: "@preact/preset-vite@npm:2.9.1"
|
||||
dependencies:
|
||||
"@babel/code-frame": "npm:^7.22.13"
|
||||
"@babel/plugin-transform-react-jsx": "npm:^7.22.15"
|
||||
@@ -1068,13 +1068,12 @@ __metadata:
|
||||
kolorist: "npm:^1.8.0"
|
||||
magic-string: "npm:0.30.5"
|
||||
node-html-parser: "npm:^6.1.10"
|
||||
resolve: "npm:^1.22.8"
|
||||
source-map: "npm:^0.7.4"
|
||||
stack-trace: "npm:^1.0.0-pre2"
|
||||
peerDependencies:
|
||||
"@babel/core": 7.x
|
||||
vite: 2.x || 3.x || 4.x || 5.x
|
||||
checksum: 10c0/658e3dc048d1f1d8ad7cb1fef4a3db0f933be4e00d3d6cdfbd29fe7ec02341b3a26747520a5b261992923b3d3f49800c23a4d77da849e708a5c1ad9a920343b2
|
||||
checksum: 10c0/6c2f2a7f06b08b2bd817d493101c4654891d6b86f661d48e2fb0b1388289bc4cb40b11a9ab30f9a12f818a28a1b48d60d97b24b8d3376c317a9d8abe06a68b1e
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -1417,7 +1416,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/node@npm:*, @types/node@npm:^22.5.4":
|
||||
"@types/node@npm:*":
|
||||
version: 22.5.4
|
||||
resolution: "@types/node@npm:22.5.4"
|
||||
dependencies:
|
||||
@@ -1426,6 +1425,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/node@npm:^22.5.5":
|
||||
version: 22.5.5
|
||||
resolution: "@types/node@npm:22.5.5"
|
||||
dependencies:
|
||||
undici-types: "npm:~6.19.2"
|
||||
checksum: 10c0/ead9495cfc6b1da5e7025856dcce2591e9bae635357410c0d2dd619fce797d2a1d402887580ca4b336cb78168b195224869967de370a23f61663cf1e4836121c
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/parse-json@npm:^4.0.0":
|
||||
version: 4.0.2
|
||||
resolution: "@types/parse-json@npm:4.0.2"
|
||||
@@ -1635,11 +1643,11 @@ __metadata:
|
||||
"@mui/icons-material": "npm:^6.1.0"
|
||||
"@mui/material": "npm:^6.1.0"
|
||||
"@preact/compat": "npm:^18.3.1"
|
||||
"@preact/preset-vite": "npm:^2.9.0"
|
||||
"@preact/preset-vite": "npm:^2.9.1"
|
||||
"@table-library/react-table-library": "npm:4.1.7"
|
||||
"@trivago/prettier-plugin-sort-imports": "npm:^4.3.0"
|
||||
"@types/formidable": "npm:^3"
|
||||
"@types/node": "npm:^22.5.4"
|
||||
"@types/node": "npm:^22.5.5"
|
||||
"@types/react": "npm:^18.3.5"
|
||||
"@types/react-dom": "npm:^18.3.0"
|
||||
"@types/react-router-dom": "npm:^5.3.3"
|
||||
@@ -1651,7 +1659,7 @@ __metadata:
|
||||
formidable: "npm:^3.5.1"
|
||||
jwt-decode: "npm:^4.0.0"
|
||||
mime-types: "npm:^2.1.35"
|
||||
preact: "npm:^10.23.2"
|
||||
preact: "npm:^10.24.0"
|
||||
prettier: "npm:^3.3.3"
|
||||
react: "npm:^18.3.1"
|
||||
react-dom: "npm:^18.3.1"
|
||||
@@ -1663,7 +1671,7 @@ __metadata:
|
||||
typesafe-i18n: "npm:^5.26.2"
|
||||
typescript: "npm:^5.6.2"
|
||||
typescript-eslint: "npm:8.5.0"
|
||||
vite: "npm:^5.4.4"
|
||||
vite: "npm:^5.4.5"
|
||||
vite-plugin-imagemin: "npm:^0.6.1"
|
||||
vite-tsconfig-paths: "npm:^5.0.1"
|
||||
languageName: unknown
|
||||
@@ -5568,10 +5576,10 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"preact@npm:^10.23.2":
|
||||
version: 10.23.2
|
||||
resolution: "preact@npm:10.23.2"
|
||||
checksum: 10c0/6e0dc1b38ead7554c99ddec9a32162b456e8f622229413b136042a777445a12d115633cd49d6df83c30b64d721a0ad4d3c71bb468edc759c15799896e96fd9f2
|
||||
"preact@npm:^10.24.0":
|
||||
version: 10.24.0
|
||||
resolution: "preact@npm:10.24.0"
|
||||
checksum: 10c0/09d490d2326c511e205a96f81db0adf05f1b42dbe2a39be6fc494662c7476575494e96140252f351a0e3b3d15aee5b079bf963865bb01287f69c45c6755ed22e
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -5897,7 +5905,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"resolve@npm:^1.10.0, resolve@npm:^1.19.0, resolve@npm:^1.22.8":
|
||||
"resolve@npm:^1.10.0, resolve@npm:^1.19.0":
|
||||
version: 1.22.8
|
||||
resolution: "resolve@npm:1.22.8"
|
||||
dependencies:
|
||||
@@ -5910,7 +5918,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"resolve@patch:resolve@npm%3A^1.10.0#optional!builtin<compat/resolve>, resolve@patch:resolve@npm%3A^1.19.0#optional!builtin<compat/resolve>, resolve@patch:resolve@npm%3A^1.22.8#optional!builtin<compat/resolve>":
|
||||
"resolve@patch:resolve@npm%3A^1.10.0#optional!builtin<compat/resolve>, resolve@patch:resolve@npm%3A^1.19.0#optional!builtin<compat/resolve>":
|
||||
version: 1.22.8
|
||||
resolution: "resolve@patch:resolve@npm%3A1.22.8#optional!builtin<compat/resolve>::version=1.22.8&hash=c3c19d"
|
||||
dependencies:
|
||||
@@ -6960,9 +6968,9 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"vite@npm:^5.4.4":
|
||||
version: 5.4.4
|
||||
resolution: "vite@npm:5.4.4"
|
||||
"vite@npm:^5.4.5":
|
||||
version: 5.4.5
|
||||
resolution: "vite@npm:5.4.5"
|
||||
dependencies:
|
||||
esbuild: "npm:^0.21.3"
|
||||
fsevents: "npm:~2.3.3"
|
||||
@@ -6999,7 +7007,7 @@ __metadata:
|
||||
optional: true
|
||||
bin:
|
||||
vite: bin/vite.js
|
||||
checksum: 10c0/2752e7dd5584ea7cc057742e8f5cbf2f2bd3a2bceb8794fbd3d52f1e88d362b5ac7f1c70be7a3d01b3d768320c8a8ad0df287fd72f253bf040423c36c67a3e89
|
||||
checksum: 10c0/89c6459452fc238cdf8e99681b30996af171c9c557af476f96408a18a639fb5a0a6ee2d2257e005b21dc284edceb604595c34920cd4a007ad18f7ebafb654c76
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
@@ -34,18 +34,25 @@ except ImportError:
|
||||
from termcolor import cprint
|
||||
|
||||
def print_success(x): return cprint(x, 'green')
|
||||
def print_fail(x): return cprint(x, 'red')
|
||||
def print_fail(x): return cprint('Error: '+x, 'red')
|
||||
|
||||
def on_upload(source, target, env):
|
||||
|
||||
# make sure we have set the upload_protocol to custom
|
||||
if env.get('UPLOAD_PROTOCOL') != 'custom':
|
||||
print_fail("Please set upload_protocol = custom in your pio_local.ini file when using upload.py")
|
||||
return
|
||||
|
||||
# first check authentication
|
||||
try:
|
||||
username = env.GetProjectOption('custom_username')
|
||||
password = env.GetProjectOption('custom_password')
|
||||
emsesp_ip = env.GetProjectOption('custom_emsesp_ip')
|
||||
except:
|
||||
print('No authentication settings specified. Please, add these to your pio_local.ini file: \n\ncustom_username=username\ncustom_password=password\n')
|
||||
print_fail('Missing settings. Add these to your pio_local.ini file: \n\ncustom_username=username\ncustom_password=password\ncustom_emsesp_ip=ems-esp.local\n')
|
||||
return
|
||||
|
||||
|
||||
emsesp_url = "http://" + env.GetProjectOption('custom_emsesp_ip')
|
||||
parsed_url = urlparse(emsesp_url)
|
||||
host_ip = parsed_url.netloc
|
||||
@@ -71,10 +78,10 @@ def on_upload(source, target, env):
|
||||
response = requests.post(signon_url, json=username_password, headers=signon_headers)
|
||||
|
||||
if response.status_code != 200:
|
||||
print_fail("Authentication failed (code " + str(response.status_code) + ")")
|
||||
print_fail("Authentication with EMS-ESP failed (code " + str(response.status_code) + ")")
|
||||
return
|
||||
|
||||
print_success("Authentication successful")
|
||||
print_success("Authentication with EMS-ESP successful")
|
||||
access_token = response.json().get('access_token')
|
||||
|
||||
# start the upload
|
||||
|
||||
@@ -76,6 +76,9 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
//
|
||||
// Show commands
|
||||
//
|
||||
commands->add_command(ShellContext::MAIN, CommandFlags::USER, {F_(show)}, [=](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
to_app(shell).system_.show_system(shell);
|
||||
});
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::USER,
|
||||
string_vector{F_(show), F_(system)},
|
||||
@@ -125,7 +128,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
// create commands test
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::USER,
|
||||
string_vector{"test"},
|
||||
{"test"},
|
||||
string_vector{F_(name_optional), F_(data_optional), F_(id_optional)},
|
||||
[=](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments.empty()) {
|
||||
@@ -138,12 +141,12 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
Test::run_test(shell, arguments[0].c_str(), arguments[1].c_str(), arguments[2].c_str());
|
||||
}
|
||||
});
|
||||
commands->add_command(ShellContext::MAIN, CommandFlags::USER, string_vector{"t"}, [=](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
commands->add_command(ShellContext::MAIN, CommandFlags::USER, {"t"}, [=](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
Test::run_test(shell, "default");
|
||||
});
|
||||
#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, {F_(su)}, [=](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
auto become_admin = [](Shell & shell) {
|
||||
shell.logger().log(LogLevel::NOTICE, LogFacility::AUTH, F("Admin session opened on console %s"), to_shell(shell).console_name().c_str());
|
||||
shell.add_flags(CommandFlags::ADMIN);
|
||||
@@ -176,7 +179,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
}
|
||||
});
|
||||
|
||||
commands->add_command(ShellContext::MAIN, CommandFlags::ADMIN, string_vector{F_(passwd)}, [](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
commands->add_command(ShellContext::MAIN, CommandFlags::ADMIN, {F_(passwd)}, [](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
shell.enter_password(F_(new_password_prompt1), [](Shell & shell, bool completed, const std::string & password1) {
|
||||
if (completed) {
|
||||
shell.enter_password(F_(new_password_prompt2), [password1](Shell & shell, bool completed, const std::string & password2) {
|
||||
@@ -198,8 +201,8 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::ADMIN,
|
||||
string_vector{F_(restart)},
|
||||
string_vector{F_(partitionname_optional)},
|
||||
{F_(restart)},
|
||||
{F_(partitionname_optional)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments.size()) {
|
||||
to_app(shell).system_.system_restart(arguments.front().c_str());
|
||||
@@ -244,7 +247,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::ADMIN,
|
||||
string_vector{F_(set), F_(hostname)},
|
||||
string_vector{F_(name_mandatory)},
|
||||
{F_(name_mandatory)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
shell.println("The network connection will be reset...");
|
||||
Shell::loop_all();
|
||||
@@ -258,7 +261,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::ADMIN,
|
||||
string_vector{F_(set), F_(wifi), F_(ssid)},
|
||||
string_vector{F_(name_mandatory)},
|
||||
{F_(name_mandatory)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
to_app(shell).esp8266React.getNetworkSettingsService()->updateWithoutPropagation([&](NetworkSettings & networkSettings) {
|
||||
networkSettings.ssid = arguments.front().c_str();
|
||||
@@ -273,7 +276,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
ShellContext::MAIN,
|
||||
CommandFlags::ADMIN,
|
||||
string_vector{F_(set), F_(board_profile)},
|
||||
string_vector{F_(name_mandatory)},
|
||||
{F_(name_mandatory)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
std::vector<int8_t> data; // led, dallas, rx, tx, button, phy_type, eth_power, eth_phy_addr, eth_clock_mode
|
||||
std::string board_profile = Helpers::toUpper(arguments.front());
|
||||
@@ -303,7 +306,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
ShellContext::MAIN,
|
||||
CommandFlags::ADMIN,
|
||||
string_vector{F_(set), F_(bus_id)},
|
||||
string_vector{F_(deviceid_mandatory)},
|
||||
{F_(deviceid_mandatory)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
uint8_t device_id = Helpers::hextoint(arguments.front().c_str());
|
||||
if ((device_id == 0x0B) || (device_id == 0x0D) || (device_id == 0x0A) || (device_id == 0x0F) || (device_id == 0x12)) {
|
||||
@@ -323,7 +326,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::ADMIN,
|
||||
string_vector{F_(set), F_(tx_mode)},
|
||||
string_vector{F_(n_mandatory)},
|
||||
{F_(n_mandatory)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
uint8_t tx_mode = std::strtol(arguments[0].c_str(), nullptr, 10);
|
||||
// save the tx_mode
|
||||
@@ -371,30 +374,25 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
// EMS device commands
|
||||
//
|
||||
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::ADMIN,
|
||||
string_vector{F_(scan)},
|
||||
string_vector{F_(deep_optional)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments.size() == 0) {
|
||||
to_app(shell).scan_devices();
|
||||
} else {
|
||||
shell.printfln("Performing a deep scan...");
|
||||
to_app(shell).clear_all_devices();
|
||||
// device IDs taken from device_library.h
|
||||
// send the read command with Version command
|
||||
const std::vector<uint8_t> Device_Ids = {0x02, 0x08, 0x09, 0x10, 0x11, 0x12, 0x15, 0x17, 0x18, 0x19, 0x1A,
|
||||
0x1B, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
|
||||
0x2A, 0x30, 0x38, 0x40, 0x41, 0x48, 0x50, 0x51, 0x60};
|
||||
for (const uint8_t device_id : Device_Ids) {
|
||||
to_app(shell).send_read_request(EMSdevice::EMS_TYPE_VERSION, device_id);
|
||||
}
|
||||
}
|
||||
});
|
||||
commands->add_command(ShellContext::MAIN, CommandFlags::ADMIN, {F_(scan)}, {F_(deep_optional)}, [](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments.size() == 0) {
|
||||
to_app(shell).scan_devices();
|
||||
} else {
|
||||
shell.printfln("Performing a deep scan...");
|
||||
to_app(shell).clear_all_devices();
|
||||
// device IDs taken from device_library.h
|
||||
// send the read command with Version command
|
||||
const std::vector<uint8_t> Device_Ids = {0x02, 0x08, 0x09, 0x10, 0x11, 0x12, 0x15, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x20, 0x21, 0x22, 0x23,
|
||||
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x30, 0x38, 0x40, 0x41, 0x48, 0x50, 0x51, 0x60};
|
||||
for (const uint8_t device_id : Device_Ids) {
|
||||
to_app(shell).send_read_request(EMSdevice::EMS_TYPE_VERSION, device_id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::USER,
|
||||
string_vector{F_(read)},
|
||||
{F_(read)},
|
||||
string_vector{F_(deviceid_mandatory), F_(typeid_mandatory), F_(offset_optional), F_(length_optional)},
|
||||
[=](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
uint8_t device_id = Helpers::hextoint(arguments.front().c_str());
|
||||
@@ -420,7 +418,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::USER,
|
||||
string_vector{F_(watch)},
|
||||
{F_(watch)},
|
||||
string_vector{F_(watch_format_optional), F_(watchid_optional)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
uint16_t watch_id = WATCH_ID_NONE;
|
||||
@@ -490,7 +488,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
commands->add_command(
|
||||
ShellContext::MAIN,
|
||||
CommandFlags::ADMIN,
|
||||
string_vector{F_(call)},
|
||||
{F_(call)},
|
||||
string_vector{F_(device_type_optional), F_(cmd_optional), F_(data_optional), F_(id_optional)},
|
||||
[&](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments.empty()) {
|
||||
|
||||
@@ -578,7 +578,7 @@ void EMSdevice::add_device_value(int8_t tag, // to b
|
||||
snprintf(entity, sizeof(entity), "%s/%s", tag_to_mqtt(tag), short_name);
|
||||
}
|
||||
|
||||
for (std::string entity_id : entityCustomization.entity_ids) {
|
||||
for (const std::string & entity_id : entityCustomization.entity_ids) {
|
||||
// if there is an appended custom name, strip it to get the true entity name
|
||||
// and extract the new custom name
|
||||
auto custom_name_pos = entity_id.find('|');
|
||||
@@ -1112,7 +1112,7 @@ void EMSdevice::generate_values_web_customization(JsonArray output) {
|
||||
EMSESP::webCustomizationService.read([&](WebCustomization & settings) {
|
||||
for (EntityCustomization entityCustomization : settings.entityCustomizations) {
|
||||
if (entityCustomization.device_id == device_id()) {
|
||||
for (std::string entity_id : entityCustomization.entity_ids) {
|
||||
for (const std::string & entity_id : entityCustomization.entity_ids) {
|
||||
uint8_t mask = Helpers::hextoint(entity_id.substr(0, 2).c_str());
|
||||
if (mask & 0x80) {
|
||||
JsonObject obj = output.add<JsonObject>();
|
||||
|
||||
@@ -369,7 +369,7 @@ std::string DeviceValue::get_fullname() const {
|
||||
return customname;
|
||||
}
|
||||
|
||||
std::string DeviceValue::get_name(std::string & entity) {
|
||||
std::string DeviceValue::get_name(const std::string & entity) {
|
||||
auto pos = entity.find('|');
|
||||
if (pos != std::string::npos) {
|
||||
return entity.substr(2, pos - 2);
|
||||
|
||||
@@ -188,7 +188,7 @@ class DeviceValue {
|
||||
bool get_custom_max(uint32_t & val);
|
||||
std::string get_custom_fullname() const;
|
||||
std::string get_fullname() const;
|
||||
static std::string get_name(std::string & entity);
|
||||
static std::string get_name(const std::string & entity);
|
||||
|
||||
// dv state flags
|
||||
void add_state(uint8_t s) {
|
||||
|
||||
@@ -1579,12 +1579,10 @@ void EMSESP::start() {
|
||||
esp8266React.begin();
|
||||
|
||||
#ifndef EMSESP_STANDALONE
|
||||
LOG_INFO("Booting EMS-ESP version %s from %s/%s partition",
|
||||
EMSESP_APP_VERSION,
|
||||
esp_ota_get_boot_partition()->label,
|
||||
LOG_INFO("EMS-ESP version %s (%s partition)", EMSESP_APP_VERSION,
|
||||
esp_ota_get_running_partition()->label); // welcome message
|
||||
#else
|
||||
LOG_INFO("Booting EMS-ESP version %s", EMSESP_APP_VERSION); // welcome message
|
||||
LOG_INFO("EMS-ESP version %s", EMSESP_APP_VERSION); // welcome message
|
||||
#endif
|
||||
LOG_DEBUG("System is running in Debug mode");
|
||||
LOG_INFO("Last system reset reason Core0: %s, Core1: %s", system_.reset_reason(0).c_str(), system_.reset_reason(1).c_str());
|
||||
|
||||
@@ -337,6 +337,12 @@ void System::system_restart(const char * partitionname) {
|
||||
Shell::loop_all(); // flush log to output
|
||||
delay(1000); // wait 1 second
|
||||
ESP.restart();
|
||||
#else
|
||||
if (partitionname != nullptr) {
|
||||
LOG_INFO("Restarting EMS-ESP from %s partition", partitionname);
|
||||
} else {
|
||||
LOG_INFO("Restarting EMS-ESP...");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -999,7 +1005,7 @@ void System::show_system(uuid::console::Shell & shell) {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
shell.printfln(" Platform: %s (%s)", EMSESP_PLATFORM, ESP.getChipModel());
|
||||
shell.printfln(" Model: %s", getBBQKeesGatewayDetails().c_str());
|
||||
shell.printfln(" Partition boot/running: %s/%s", esp_ota_get_boot_partition()->label, esp_ota_get_running_partition()->label);
|
||||
shell.printfln(" Partition: %s", esp_ota_get_running_partition()->label);
|
||||
#endif
|
||||
shell.printfln(" Language: %s", locale().c_str());
|
||||
shell.printfln(" Board profile: %s", board_profile().c_str());
|
||||
@@ -1442,17 +1448,16 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
|
||||
node["uptime"] = uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3);
|
||||
node["uptimeSec"] = uuid::get_uptime_sec();
|
||||
#ifndef EMSESP_STANDALONE
|
||||
node["platform"] = EMSESP_PLATFORM;
|
||||
node["cpuType"] = ESP.getChipModel();
|
||||
node["arduino"] = ARDUINO_VERSION;
|
||||
node["sdk"] = ESP.getSdkVersion();
|
||||
node["freeMem"] = getHeapMem();
|
||||
node["maxAlloc"] = getMaxAllocMem();
|
||||
node["freeCaps"] = heap_caps_get_free_size(MALLOC_CAP_8BIT) / 1024; // includes heap and psram
|
||||
node["usedApp"] = EMSESP::system_.appUsed(); // kilobytes
|
||||
node["freeApp"] = EMSESP::system_.appFree(); // kilobytes
|
||||
node["partitionBootRunning"] = std::string(esp_ota_get_boot_partition()->label) + "/"
|
||||
+ esp_ota_get_running_partition()->label; // will sycle app0/app0 - app1/app1 after OTA. boot/factory is on first install.
|
||||
node["platform"] = EMSESP_PLATFORM;
|
||||
node["cpuType"] = ESP.getChipModel();
|
||||
node["arduino"] = ARDUINO_VERSION;
|
||||
node["sdk"] = ESP.getSdkVersion();
|
||||
node["freeMem"] = getHeapMem();
|
||||
node["maxAlloc"] = getMaxAllocMem();
|
||||
node["freeCaps"] = heap_caps_get_free_size(MALLOC_CAP_8BIT) / 1024; // includes heap and psram
|
||||
node["usedApp"] = EMSESP::system_.appUsed(); // kilobytes
|
||||
node["freeApp"] = EMSESP::system_.appFree(); // kilobytes
|
||||
node["partition"] = esp_ota_get_running_partition()->label; // active partition
|
||||
#endif
|
||||
node["resetReason"] = EMSESP::system_.reset_reason(0) + " / " + EMSESP::system_.reset_reason(1);
|
||||
#ifndef EMSESP_STANDALONE
|
||||
|
||||
@@ -201,7 +201,7 @@ class System {
|
||||
return hostname_;
|
||||
}
|
||||
|
||||
void hostname(std::string hostname) {
|
||||
void hostname(const std::string hostname) {
|
||||
hostname_ = hostname;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ void WebCustomization::read(WebCustomization & customizations, JsonObject root)
|
||||
|
||||
// entries are in the form <XX><shortname>[optional customname] e.g "08heatingactive|heating is on"
|
||||
JsonArray masked_entityJson = entityJson["entity_ids"].to<JsonArray>();
|
||||
for (std::string entity_id : entityCustomization.entity_ids) {
|
||||
for (const std::string & entity_id : entityCustomization.entity_ids) {
|
||||
masked_entityJson.add(entity_id);
|
||||
}
|
||||
}
|
||||
@@ -277,7 +277,7 @@ void WebCustomizationService::customization_entities(AsyncWebServerRequest * req
|
||||
read([&](WebCustomization & settings) {
|
||||
for (EntityCustomization entityCustomization : settings.entityCustomizations) {
|
||||
if (entityCustomization.device_id == device_id) {
|
||||
for (std::string entity_id : entityCustomization.entity_ids) {
|
||||
for (const std::string & entity_id : entityCustomization.entity_ids) {
|
||||
uint8_t mask = Helpers::hextoint(entity_id.substr(0, 2).c_str());
|
||||
std::string name = DeviceValue::get_name(entity_id);
|
||||
if (mask & 0x80) {
|
||||
|
||||
@@ -65,7 +65,6 @@ class WebLogService : public uuid::log::Handler {
|
||||
|
||||
char * messagetime(char * out, const uint64_t t, const size_t bufsize);
|
||||
|
||||
uint64_t last_transmit_ = 0; // Last transmit time
|
||||
size_t maximum_log_messages_ = MAX_LOG_MESSAGES; // Maximum number of log messages to buffer before they are output
|
||||
size_t limit_log_messages_ = 1; // dynamic limit
|
||||
unsigned long log_message_id_ = 0; // The next identifier to use for queued log messages
|
||||
|
||||
@@ -152,7 +152,7 @@ void WebStatusService::checkUpgrade(AsyncWebServerRequest * request, JsonVariant
|
||||
JsonObject root = response->getRoot();
|
||||
|
||||
version::Semver200_version settings_version(EMSESP_APP_VERSION);
|
||||
std::string latest_version = json["version"] | EMSESP_APP_VERSION;
|
||||
const std::string latest_version = json["version"] | EMSESP_APP_VERSION;
|
||||
version::Semver200_version this_version(latest_version);
|
||||
|
||||
#ifdef EMSESP_DEBUG
|
||||
@@ -170,7 +170,8 @@ void WebStatusService::exportData(AsyncWebServerRequest * request) {
|
||||
auto * response = new AsyncJsonResponse();
|
||||
JsonObject root = response->getRoot();
|
||||
|
||||
String type = request->getParam("type")->value();
|
||||
String type = request->getParam("type")->value();
|
||||
root["type"] = type;
|
||||
|
||||
if (type == "settings") {
|
||||
JsonObject node = root["System"].to<JsonObject>();
|
||||
@@ -192,7 +193,6 @@ void WebStatusService::exportData(AsyncWebServerRequest * request) {
|
||||
return;
|
||||
}
|
||||
|
||||
root["type"] = type;
|
||||
response->setLength();
|
||||
request->send(response);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user