Skip to content

Commit

Permalink
Merge pull request #1309 from MichaelDvP/dev
Browse files Browse the repository at this point in the history
Some small corrections
  • Loading branch information
proddy authored Sep 29, 2023
2 parents 5bc3bd2 + 9946755 commit f9a53cf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
24 changes: 14 additions & 10 deletions src/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,11 @@ bool Command::device_has_commands(const uint8_t device_type) {
}

if (device_type == EMSdevice::DeviceType::TEMPERATURESENSOR) {
return true;
return EMSESP::sensor_enabled();
}

if (device_type == EMSdevice::DeviceType::ANALOGSENSOR) {
return EMSESP::system_.analog_enabled();
return EMSESP::analog_enabled();
}

for (const auto & emsdevice : EMSESP::emsdevices) {
Expand All @@ -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::CUSTOM));
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::analogsensor_.analog_enabled()) {
if (EMSESP::sensor_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));
}

Expand Down Expand Up @@ -627,13 +629,15 @@ void Command::show_all(uuid::console::Shell & shell) {
show(shell, EMSdevice::DeviceType::SCHEDULER, true);

// show sensors
shell.print(COLOR_BOLD_ON);
shell.print(COLOR_YELLOW);
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::TEMPERATURESENSOR));
shell.print(COLOR_RESET);
show(shell, EMSdevice::DeviceType::TEMPERATURESENSOR, true);
if (EMSESP::sensor_enabled()) {
shell.print(COLOR_BOLD_ON);
shell.print(COLOR_YELLOW);
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::TEMPERATURESENSOR));
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_YELLOW);
shell.printf(" %s: ", EMSdevice::device_type_2_device_name(EMSdevice::DeviceType::ANALOGSENSOR));
Expand Down
9 changes: 6 additions & 3 deletions src/devices/boiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,13 +895,16 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const

void Boiler::store_energy() {
// only write if something is changed
if (nrgHeatF_ != EMSESP::nvs_.getDouble(FL_(nrgHeat)[0]) || nrgWwF_ != EMSESP::nvs_.getDouble(FL_(nrgWw)[0])
|| nomPower_ != EMSESP::nvs_.getUChar(FL_(nomPower)[0])) {
if (nrgHeatF_ != EMSESP::nvs_.getDouble(FL_(nrgHeat)[0])) {
EMSESP::nvs_.putDouble(FL_(nrgHeat)[0], nrgHeatF_);
}
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");
}
// LOG_DEBUG("energy values stored");
}

// Check if hot tap water or heating is active
Expand Down
9 changes: 5 additions & 4 deletions src/web/WebStatusService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void WebStatusService::webStatusService(AsyncWebServerRequest * request) {
statJson["f"] = EMSESP::txservice_.telegram_write_fail_count();
statJson["q"] = EMSESP::txservice_.write_quality();

if (EMSESP::temperaturesensor_.sensor_enabled()) {
if (EMSESP::sensor_enabled()) {
statJson = statsJson.createNestedObject();
statJson["id"] = 3;
statJson["s"] = EMSESP::temperaturesensor_.reads();
Expand All @@ -175,16 +175,17 @@ void WebStatusService::webStatusService(AsyncWebServerRequest * request) {
statJson["id"] = 6;
statJson["s"] = WebAPIService::api_count(); // + WebAPIService::api_fails();
statJson["f"] = WebAPIService::api_fails();
statJson["q"] =
WebAPIService::api_count() == 0 ? 100 : 100 - (uint8_t)((100 * WebAPIService::api_fails()) / (WebAPIService::api_count() + WebAPIService::api_fails()));
statJson["q"] = (WebAPIService::api_count() + WebAPIService::api_fails()) == 0
? 100
: 100 - (uint8_t)((100 * WebAPIService::api_fails()) / (WebAPIService::api_count() + WebAPIService::api_fails()));

#ifndef EMSESP_STANDALONE
if (EMSESP::system_.syslog_enabled()) {
statJson = statsJson.createNestedObject();
statJson["id"] = 7;
statJson["s"] = EMSESP::system_.syslog_count();
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 - (uint8_t)((100 * EMSESP::system_.syslog_fails()) / (EMSESP::system_.syslog_count() + EMSESP::system_.syslog_fails()));
}
Expand Down

0 comments on commit f9a53cf

Please sign in to comment.