fix coldshot command with dhw tag, restart coldshot timer

This commit is contained in:
MichaelDvP
2024-04-21 10:39:17 +02:00
parent 8c7b0a674f
commit 0eb04b9027
6 changed files with 14 additions and 10 deletions

View File

@@ -281,13 +281,13 @@ const char * Command::parse_command_string(const char * command, int8_t & id) {
} }
// calls a command directly // 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 // create a temporary buffer
JsonDocument output_doc; JsonDocument output_doc;
JsonObject output = output_doc.to<JsonObject>(); JsonObject output = output_doc.to<JsonObject>();
// authenticated is always true and ID is the default value // 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. // calls a command. Takes a json object for output.

View File

@@ -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, 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 // with normal call back function taking a value and id
static void add(const uint8_t device_type, static void add(const uint8_t device_type,

View File

@@ -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' // 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) { bool Boiler::set_tapwarmwater_activated(const char * value, const int8_t id) {
// as it's a command it may not initially exist // as it's a command it may not initially exist
// if (!Helpers::hasValue(wwTapActivated_, EMS_VALUE_BOOL)) { if (!Helpers::hasValue(wwTapActivated_, EMS_VALUE_BOOL)) {
// return false; LOG_WARNING("Coldshot not possible in dhw-buffer systems");
// } return false;
}
bool v; bool v;
if (!Helpers::value2bool(value, v)) { if (!Helpers::value2bool(value, v)) {

View File

@@ -74,6 +74,7 @@ void Shower::loop() {
doing_cold_shot_ = false; doing_cold_shot_ = false;
duration_ = 0; duration_ = 0;
shower_state_ = false; shower_state_ = false;
next_alert_ = shower_alert_trigger_;
} else { } else {
// hot water has been on for a while // 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 // 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"); 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 ((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(); shower_alert_start();
} }
} }
@@ -141,7 +142,7 @@ void Shower::loop() {
// turn off hot water to send a shot of cold // turn off hot water to send a shot of cold
void Shower::shower_alert_start() { void Shower::shower_alert_start() {
LOG_DEBUG("Shower Alert started"); 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; doing_cold_shot_ = true;
force_coldshot = false; force_coldshot = false;
alert_timer_start_ = uuid::get_uptime(); // timer starts now alert_timer_start_ = uuid::get_uptime(); // timer starts now
@@ -151,9 +152,10 @@ void Shower::shower_alert_start() {
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, "dhw/tapactivated", "true"); (void)Command::call(EMSdevice::DeviceType::BOILER, "tapactivated", "true", 9);
doing_cold_shot_ = false; doing_cold_shot_ = false;
force_coldshot = false; force_coldshot = false;
next_alert_ += shower_alert_trigger_;
} }
} }

View File

@@ -49,6 +49,7 @@ class Shower {
bool shower_alert_; // true if we want the alert of cold water 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_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 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 ha_configdone_ = false; // for HA MQTT Discovery
bool shower_state_; bool shower_state_;
uint32_t timer_start_; // ms uint32_t timer_start_; // ms

View File

@@ -680,7 +680,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
test("boiler"); test("boiler");
// device type, command, data // device type, command, data
Command::call(EMSdevice::DeviceType::BOILER, "tapactivated", "false"); Command::call(EMSdevice::DeviceType::BOILER, "tapactivated", "false", 9);
ok = true; ok = true;
} }