diff --git a/src/command.cpp b/src/command.cpp index 4684fac55..81e0518fc 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -281,13 +281,13 @@ const char * Command::parse_command_string(const char * command, int8_t & id) { } // calls a command directly -uint8_t Command::call(const uint8_t device_type, const char * cmd, const char * value) { +uint8_t Command::call(const uint8_t device_type, const char * cmd, const char * value, const int8_t id) { // create a temporary buffer JsonDocument output_doc; JsonObject output = output_doc.to(); // authenticated is always true and ID is the default value - return call(device_type, cmd, value, true, -1, output); + return call(device_type, cmd, value, true, id, output); } // calls a command. Takes a json object for output. diff --git a/src/command.h b/src/command.h index b6937a4fc..337179efc 100644 --- a/src/command.h +++ b/src/command.h @@ -98,7 +98,7 @@ class Command { } static uint8_t call(const uint8_t device_type, const char * cmd, const char * value, const bool is_admin, const int8_t id, JsonObject output); - static uint8_t call(const uint8_t device_type, const char * cmd, const char * value); + static uint8_t call(const uint8_t device_type, const char * cmd, const char * value, const int8_t id = -1); // with normal call back function taking a value and id static void add(const uint8_t device_type, diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index 99e1a6bfc..34a68c2cb 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -2474,9 +2474,10 @@ bool Boiler::set_ww_activated(const char * value, const int8_t id) { // Note: Using the type 0x1D to put the boiler into Test mode. This may be shown on the boiler with a flashing 'T' bool Boiler::set_tapwarmwater_activated(const char * value, const int8_t id) { // as it's a command it may not initially exist - // if (!Helpers::hasValue(wwTapActivated_, EMS_VALUE_BOOL)) { - // return false; - // } + if (!Helpers::hasValue(wwTapActivated_, EMS_VALUE_BOOL)) { + LOG_WARNING("Coldshot not possible in dhw-buffer systems"); + return false; + } bool v; if (!Helpers::value2bool(value, v)) { diff --git a/src/shower.cpp b/src/shower.cpp index ca0d557a1..73ff9184e 100644 --- a/src/shower.cpp +++ b/src/shower.cpp @@ -74,6 +74,7 @@ void Shower::loop() { doing_cold_shot_ = false; duration_ = 0; shower_state_ = false; + next_alert_ = shower_alert_trigger_; } else { // hot water has been on for a while // first check to see if hot water has been on long enough to be recognized as a Shower/Bath @@ -82,7 +83,7 @@ void Shower::loop() { LOG_DEBUG("hot water still running, starting shower timer"); } // check if the shower has been on too long - else if ((shower_alert_ && ((time_now - timer_start_) > shower_alert_trigger_)) || force_coldshot) { + else if ((shower_alert_ && ((time_now - timer_start_) > next_alert_)) || force_coldshot) { shower_alert_start(); } } @@ -141,7 +142,7 @@ 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, "dhw/tapactivated", "false"); + (void)Command::call(EMSdevice::DeviceType::BOILER, "tapactivated", "false", 9); doing_cold_shot_ = true; force_coldshot = false; alert_timer_start_ = uuid::get_uptime(); // timer starts now @@ -151,9 +152,10 @@ void Shower::shower_alert_start() { void Shower::shower_alert_stop() { if (doing_cold_shot_) { LOG_DEBUG("Shower Alert stopped"); - (void)Command::call(EMSdevice::DeviceType::BOILER, "dhw/tapactivated", "true"); + (void)Command::call(EMSdevice::DeviceType::BOILER, "tapactivated", "true", 9); doing_cold_shot_ = false; force_coldshot = false; + next_alert_ += shower_alert_trigger_; } } diff --git a/src/shower.h b/src/shower.h index fc60c8037..e16fce391 100644 --- a/src/shower.h +++ b/src/shower.h @@ -49,6 +49,7 @@ class Shower { bool shower_alert_; // true if we want the alert of cold water uint32_t shower_alert_trigger_; // default 7 minutes, before trigger a shot of cold water uint32_t shower_alert_coldshot_; // default 10 seconds for cold water before turning back hot water + uint32_t next_alert_; bool ha_configdone_ = false; // for HA MQTT Discovery bool shower_state_; uint32_t timer_start_; // ms diff --git a/src/test/test.cpp b/src/test/test.cpp index 71dc3a2bc..b9ccce3c6 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -680,7 +680,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const test("boiler"); // device type, command, data - Command::call(EMSdevice::DeviceType::BOILER, "tapactivated", "false"); + Command::call(EMSdevice::DeviceType::BOILER, "tapactivated", "false", 9); ok = true; }