mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 16:59:50 +03:00
commands showertimer, showeralert work instant and permanent, move to shower.cpp
This commit is contained in:
@@ -51,6 +51,48 @@ void Shower::start() {
|
|||||||
FL_(coldshot_cmd),
|
FL_(coldshot_cmd),
|
||||||
CommandFlag::ADMIN_ONLY);
|
CommandFlag::ADMIN_ONLY);
|
||||||
|
|
||||||
|
Command::add(
|
||||||
|
EMSdevice::DeviceType::SYSTEM,
|
||||||
|
F_(showertimer),
|
||||||
|
[&](const char * value, const int8_t id, JsonObject output) {
|
||||||
|
bool b;
|
||||||
|
if (!Helpers::value2bool(value, b)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
shower_timer_ = b;
|
||||||
|
EMSESP::webSettingsService.update([&](WebSettings & settings) {
|
||||||
|
if (settings.shower_timer != b) {
|
||||||
|
settings.shower_timer = b;
|
||||||
|
return StateUpdateResult::CHANGED;
|
||||||
|
}
|
||||||
|
return StateUpdateResult::UNCHANGED;
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
FL_(showertimer_cmd),
|
||||||
|
CommandFlag::ADMIN_ONLY);
|
||||||
|
|
||||||
|
Command::add(
|
||||||
|
EMSdevice::DeviceType::SYSTEM,
|
||||||
|
F_(showeralert),
|
||||||
|
[&](const char * value, const int8_t id, JsonObject output) {
|
||||||
|
bool b;
|
||||||
|
if (!Helpers::value2bool(value, b)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
shower_alert_ = b;
|
||||||
|
EMSESP::webSettingsService.update([&](WebSettings & settings) {
|
||||||
|
if (settings.shower_alert != b) {
|
||||||
|
settings.shower_alert = b;
|
||||||
|
return StateUpdateResult::CHANGED;
|
||||||
|
}
|
||||||
|
return StateUpdateResult::UNCHANGED;
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
FL_(showeralert_cmd),
|
||||||
|
CommandFlag::ADMIN_ONLY);
|
||||||
|
|
||||||
if (shower_timer_) {
|
if (shower_timer_) {
|
||||||
set_shower_state(false, true); // turns shower to off and creates HA topic if not already done
|
set_shower_state(false, true); // turns shower to off and creates HA topic if not already done
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,37 +196,6 @@ bool System::command_syslog_level(const char * value, const int8_t id) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// shower timer
|
|
||||||
bool System::command_showertimer(const char * value, const int8_t id) {
|
|
||||||
bool b;
|
|
||||||
if (Helpers::value2bool(value, b)) {
|
|
||||||
EMSESP::webSettingsService.update([&](WebSettings & settings) {
|
|
||||||
if (settings.shower_timer != b) {
|
|
||||||
settings.shower_timer = b;
|
|
||||||
return StateUpdateResult::CHANGED;
|
|
||||||
}
|
|
||||||
return StateUpdateResult::UNCHANGED;
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// shower alert
|
|
||||||
bool System::command_showeralert(const char * value, const int8_t id) {
|
|
||||||
bool b;
|
|
||||||
if (Helpers::value2bool(value, b)) {
|
|
||||||
EMSESP::webSettingsService.update([&](WebSettings & settings) {
|
|
||||||
if (settings.shower_alert != b) {
|
|
||||||
settings.shower_alert = b;
|
|
||||||
return StateUpdateResult::CHANGED;
|
|
||||||
}
|
|
||||||
return StateUpdateResult::UNCHANGED;
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// send message - to log and MQTT
|
// send message - to log and MQTT
|
||||||
bool System::command_message(const char * value, const int8_t id) {
|
bool System::command_message(const char * value, const int8_t id) {
|
||||||
@@ -891,8 +860,6 @@ void System::commands_init() {
|
|||||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(format), System::command_format, FL_(format_cmd), CommandFlag::ADMIN_ONLY);
|
Command::add(EMSdevice::DeviceType::SYSTEM, F_(format), System::command_format, FL_(format_cmd), CommandFlag::ADMIN_ONLY);
|
||||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(watch), System::command_watch, FL_(watch_cmd));
|
Command::add(EMSdevice::DeviceType::SYSTEM, F_(watch), System::command_watch, FL_(watch_cmd));
|
||||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(message), System::command_message, FL_(message_cmd));
|
Command::add(EMSdevice::DeviceType::SYSTEM, F_(message), System::command_message, FL_(message_cmd));
|
||||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(showertimer), System::command_showertimer, FL_(showertimer_cmd), CommandFlag::ADMIN_ONLY);
|
|
||||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(showeralert), System::command_showeralert, FL_(showeralert_cmd), CommandFlag::ADMIN_ONLY);
|
|
||||||
#if defined(EMSESP_TEST)
|
#if defined(EMSESP_TEST)
|
||||||
Command::add(EMSdevice::DeviceType::SYSTEM, ("test"), System::command_test, FL_(test_cmd));
|
Command::add(EMSdevice::DeviceType::SYSTEM, ("test"), System::command_test, FL_(test_cmd));
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -69,8 +69,6 @@ class System {
|
|||||||
static bool command_fetch(const char * value, const int8_t id);
|
static bool command_fetch(const char * value, const int8_t id);
|
||||||
static bool command_restart(const char * value, const int8_t id);
|
static bool command_restart(const char * value, const int8_t id);
|
||||||
static bool command_format(const char * value, const int8_t id);
|
static bool command_format(const char * value, const int8_t id);
|
||||||
static bool command_showertimer(const char * value, const int8_t id);
|
|
||||||
static bool command_showeralert(const char * value, const int8_t id);
|
|
||||||
static bool command_watch(const char * value, const int8_t id);
|
static bool command_watch(const char * value, const int8_t id);
|
||||||
static bool command_message(const char * value, const int8_t id);
|
static bool command_message(const char * value, const int8_t id);
|
||||||
static bool command_info(const char * value, const int8_t id, JsonObject output);
|
static bool command_info(const char * value, const int8_t id, JsonObject output);
|
||||||
|
|||||||
Reference in New Issue
Block a user