Merge pull request #1309 from MichaelDvP/dev

Some small corrections
This commit is contained in:
Proddy
2023-09-29 11:18:24 +02:00
committed by GitHub
3 changed files with 27 additions and 19 deletions

View File

@@ -550,11 +550,11 @@ bool Command::device_has_commands(const uint8_t device_type) {
} }
if (device_type == EMSdevice::DeviceType::TEMPERATURESENSOR) { if (device_type == EMSdevice::DeviceType::TEMPERATURESENSOR) {
return true; return EMSESP::sensor_enabled();
} }
if (device_type == EMSdevice::DeviceType::ANALOGSENSOR) { if (device_type == EMSdevice::DeviceType::ANALOGSENSOR) {
return EMSESP::system_.analog_enabled(); return EMSESP::analog_enabled();
} }
for (const auto & emsdevice : EMSESP::emsdevices) { for (const auto & emsdevice : EMSESP::emsdevices) {
@@ -576,8 +576,10 @@ void Command::show_devices(uuid::console::Shell & shell) {
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::SYSTEM)); shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::SYSTEM));
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::CUSTOM)); shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::CUSTOM));
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::SCHEDULER)); shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::SCHEDULER));
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::TEMPERATURESENSOR)); if (EMSESP::sensor_enabled()) {
if (EMSESP::analogsensor_.analog_enabled()) { shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::TEMPERATURESENSOR));
}
if (EMSESP::analog_enabled()) {
shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::ANALOGSENSOR)); shell.printf("%s ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::ANALOGSENSOR));
} }
@@ -627,13 +629,15 @@ void Command::show_all(uuid::console::Shell & shell) {
show(shell, EMSdevice::DeviceType::SCHEDULER, true); show(shell, EMSdevice::DeviceType::SCHEDULER, true);
// show sensors // show sensors
shell.print(COLOR_BOLD_ON); if (EMSESP::sensor_enabled()) {
shell.print(COLOR_YELLOW); shell.print(COLOR_BOLD_ON);
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::TEMPERATURESENSOR)); shell.print(COLOR_YELLOW);
shell.print(COLOR_RESET); shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::TEMPERATURESENSOR));
show(shell, EMSdevice::DeviceType::TEMPERATURESENSOR, true); shell.print(COLOR_RESET);
show(shell, EMSdevice::DeviceType::TEMPERATURESENSOR, true);
}
if (EMSESP::analogsensor_.analog_enabled()) { if (EMSESP::analog_enabled()) {
shell.print(COLOR_BOLD_ON); shell.print(COLOR_BOLD_ON);
shell.print(COLOR_YELLOW); shell.print(COLOR_YELLOW);
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::ANALOGSENSOR)); shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::ANALOGSENSOR));

View File

@@ -895,13 +895,16 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const
void Boiler::store_energy() { void Boiler::store_energy() {
// only write if something is changed // only write if something is changed
if (nrgHeatF_ != EMSESP::nvs_.getDouble(FL_(nrgHeat)[0]) || nrgWwF_ != EMSESP::nvs_.getDouble(FL_(nrgWw)[0]) if (nrgHeatF_ != EMSESP::nvs_.getDouble(FL_(nrgHeat)[0])) {
|| nomPower_ != EMSESP::nvs_.getUChar(FL_(nomPower)[0])) {
EMSESP::nvs_.putDouble(FL_(nrgHeat)[0], nrgHeatF_); EMSESP::nvs_.putDouble(FL_(nrgHeat)[0], nrgHeatF_);
EMSESP::nvs_.putDouble(FL_(nrgWw)[0], nrgWwF_);
EMSESP::nvs_.putUChar(FL_(nomPower)[0], nomPower_);
LOG_DEBUG("energy values stored");
} }
if (nrgWwF_ != EMSESP::nvs_.getDouble(FL_(nrgWw)[0])) {
EMSESP::nvs_.putDouble(FL_(nrgWw)[0], nrgWwF_);
}
if (nomPower_ != EMSESP::nvs_.getUChar(FL_(nomPower)[0])) {
EMSESP::nvs_.putUChar(FL_(nomPower)[0], nomPower_);
}
// LOG_DEBUG("energy values stored");
} }
// Check if hot tap water or heating is active // Check if hot tap water or heating is active

View File

@@ -148,7 +148,7 @@ void WebStatusService::webStatusService(AsyncWebServerRequest * request) {
statJson["f"] = EMSESP::txservice_.telegram_write_fail_count(); statJson["f"] = EMSESP::txservice_.telegram_write_fail_count();
statJson["q"] = EMSESP::txservice_.write_quality(); statJson["q"] = EMSESP::txservice_.write_quality();
if (EMSESP::temperaturesensor_.sensor_enabled()) { if (EMSESP::sensor_enabled()) {
statJson = statsJson.createNestedObject(); statJson = statsJson.createNestedObject();
statJson["id"] = 3; statJson["id"] = 3;
statJson["s"] = EMSESP::temperaturesensor_.reads(); statJson["s"] = EMSESP::temperaturesensor_.reads();
@@ -175,8 +175,9 @@ void WebStatusService::webStatusService(AsyncWebServerRequest * request) {
statJson["id"] = 6; statJson["id"] = 6;
statJson["s"] = WebAPIService::api_count(); // + WebAPIService::api_fails(); statJson["s"] = WebAPIService::api_count(); // + WebAPIService::api_fails();
statJson["f"] = WebAPIService::api_fails(); statJson["f"] = WebAPIService::api_fails();
statJson["q"] = statJson["q"] = (WebAPIService::api_count() + WebAPIService::api_fails()) == 0
WebAPIService::api_count() == 0 ? 100 : 100 - (uint8_t)((100 * WebAPIService::api_fails()) / (WebAPIService::api_count() + WebAPIService::api_fails())); ? 100
: 100 - (uint8_t)((100 * WebAPIService::api_fails()) / (WebAPIService::api_count() + WebAPIService::api_fails()));
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
if (EMSESP::system_.syslog_enabled()) { if (EMSESP::system_.syslog_enabled()) {
@@ -184,7 +185,7 @@ void WebStatusService::webStatusService(AsyncWebServerRequest * request) {
statJson["id"] = 7; statJson["id"] = 7;
statJson["s"] = EMSESP::system_.syslog_count(); statJson["s"] = EMSESP::system_.syslog_count();
statJson["f"] = EMSESP::system_.syslog_fails(); statJson["f"] = EMSESP::system_.syslog_fails();
statJson["q"] = EMSESP::system_.syslog_count() == 0 statJson["q"] = (EMSESP::system_.syslog_count() + EMSESP::system_.syslog_fails()) == 0
? 100 ? 100
: 100 - (uint8_t)((100 * EMSESP::system_.syslog_fails()) / (EMSESP::system_.syslog_count() + EMSESP::system_.syslog_fails())); : 100 - (uint8_t)((100 * EMSESP::system_.syslog_fails()) / (EMSESP::system_.syslog_count() + EMSESP::system_.syslog_fails()));
} }