re-enable shower alert

This commit is contained in:
proddy
2021-04-04 13:38:49 +02:00
parent 7fa93a8de0
commit 4f239d035e
5 changed files with 39 additions and 18 deletions

View File

@@ -8,5 +8,6 @@
- Icon for Network - Icon for Network
- MQTT Formatting payload (nested vs single) is a pull-down option - MQTT Formatting payload (nested vs single) is a pull-down option
- moved mqtt-topics and texts to local_EN, all topics lower case - moved mqtt-topics and texts to local_EN, all topics lower case
- Re-enabled Shower Alert (still experimental)
## Removed ## Removed

View File

@@ -86,9 +86,16 @@ void Shower::loop() {
timer_start_ = 0; timer_start_ = 0;
timer_pause_ = 0; timer_pause_ = 0;
shower_on_ = false; shower_on_ = false;
shower_alert_stop(); doing_cold_shot_ = false;
alert_timer_start_ = 0;
} }
} }
return;
}
// at this point we're in the shower cold shot (doing_cold_shot_ == true)
// keep repeating until the time is up
if ((time_now - alert_timer_start_) > SHOWER_COLDSHOT_DURATION) {
} }
} }
@@ -124,20 +131,17 @@ void Shower::send_mqtt_stat(bool state, bool force) {
void Shower::shower_alert_stop() { void Shower::shower_alert_stop() {
if (doing_cold_shot_) { if (doing_cold_shot_) {
LOG_DEBUG(F("Shower Alert stopped")); LOG_DEBUG(F("Shower Alert stopped"));
// Boiler::set_tapwarmwater_activated(true); Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "true");
doing_cold_shot_ = false; doing_cold_shot_ = false;
// showerColdShotStopTimer.detach(); // disable the timer
} }
} }
// 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() {
if (shower_alert_) { if (shower_alert_) {
LOG_DEBUG(F("Shower Alert started!")); LOG_DEBUG(F("Shower Alert started"));
// Boiler::set_tapwarmwater_activated(false); Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "false");
doing_cold_shot_ = true; doing_cold_shot_ = true;
// start the timer for n seconds which will reset the water back to hot alert_timer_start_ = uuid::get_uptime(); // timer starts now
// showerColdShotStopTimer.attach(SHOWER_COLDSHOT_DURATION, _showerColdShotStop);
} }
} }

View File

@@ -52,7 +52,7 @@ class Shower {
static constexpr uint32_t SHOWER_PAUSE_TIME = 15000; // in ms. 15 seconds, max time if water is switched off & on during a shower static constexpr uint32_t SHOWER_PAUSE_TIME = 15000; // in ms. 15 seconds, max time if water is switched off & on during a shower
static constexpr uint32_t SHOWER_MIN_DURATION = 120000; // in ms. 2 minutes, before recognizing its a shower static constexpr uint32_t SHOWER_MIN_DURATION = 120000; // in ms. 2 minutes, before recognizing its a shower
static constexpr uint32_t SHOWER_OFFSET_TIME = 5000; // in ms. 5 seconds grace time, to calibrate actual time under the shower static constexpr uint32_t SHOWER_OFFSET_TIME = 5000; // in ms. 5 seconds grace time, to calibrate actual time under the shower
static constexpr uint32_t SHOWER_COLDSHOT_DURATION = 10; // in seconds. 10 seconds for cold water before turning back hot water static constexpr uint32_t SHOWER_COLDSHOT_DURATION = 10000; // 10 seconds for cold water before turning back hot water
static constexpr uint32_t SHOWER_MAX_DURATION = 420000; // in ms. 7 minutes, before trigger a shot of cold water static constexpr uint32_t SHOWER_MAX_DURATION = 420000; // in ms. 7 minutes, before trigger a shot of cold water
void publish_values(); void publish_values();
@@ -66,6 +66,9 @@ class Shower {
uint32_t timer_start_; // ms uint32_t timer_start_; // ms
uint32_t timer_pause_; // ms uint32_t timer_pause_; // ms
uint32_t duration_; // ms uint32_t duration_; // ms
// cold shot
uint32_t alert_timer_start_; // ms
bool doing_cold_shot_; // true if we've just sent a jolt of cold water bool doing_cold_shot_; // true if we've just sent a jolt of cold water
}; };

View File

@@ -399,6 +399,17 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
shell.invoke_command("show mqtt"); shell.invoke_command("show mqtt");
} }
if (command == "shower_alert") {
shell.printfln(F("Testing Shower Alert..."));
run_test("boiler");
DynamicJsonDocument doc(EMSESP_JSON_SIZE_LARGE_DYN);
JsonObject json = doc.to<JsonObject>();
// device type, command, data
Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "false");
}
if (command == "fr120") { if (command == "fr120") {
shell.printfln(F("Testing adding a thermostat FR120...")); shell.printfln(F("Testing adding a thermostat FR120..."));

View File

@@ -34,7 +34,9 @@ namespace emsesp {
// #define EMSESP_DEBUG_DEFAULT "mqtt2" // #define EMSESP_DEBUG_DEFAULT "mqtt2"
// #define EMSESP_DEBUG_DEFAULT "mqtt_nested" // #define EMSESP_DEBUG_DEFAULT "mqtt_nested"
// #define EMSESP_DEBUG_DEFAULT "ha" // #define EMSESP_DEBUG_DEFAULT "ha"
#define EMSESP_DEBUG_DEFAULT "board_profile" // #define EMSESP_DEBUG_DEFAULT "board_profile"
#define EMSESP_DEBUG_DEFAULT "shower_alert"
class Test { class Test {
public: public: