14static const char *
const TAG =
"water_heater";
32 if (
len == 3 && ESPHOME_strncasecmp_P(
mode, ESPHOME_PSTR(
"OFF"), 3) == 0) {
34 }
else if (len == 3 && ESPHOME_strncasecmp_P(
mode, ESPHOME_PSTR(
"ECO"), 3) == 0) {
36 }
else if (len == 8 && ESPHOME_strncasecmp_P(
mode, ESPHOME_PSTR(
"ELECTRIC"), 8) == 0) {
38 }
else if (len == 11 && ESPHOME_strncasecmp_P(
mode, ESPHOME_PSTR(
"PERFORMANCE"), 11) == 0) {
40 }
else if (len == 11 && ESPHOME_strncasecmp_P(
mode, ESPHOME_PSTR(
"HIGH_DEMAND"), 11) == 0) {
42 }
else if (len == 9 && ESPHOME_strncasecmp_P(
mode, ESPHOME_PSTR(
"HEAT_PUMP"), 9) == 0) {
44 }
else if (len == 3 && ESPHOME_strncasecmp_P(
mode, ESPHOME_PSTR(
"GAS"), 3) == 0) {
71 this->
state_ &= ~WATER_HEATER_STATE_AWAY;
81 this->
state_ &= ~WATER_HEATER_STATE_ON;
90 if (this->
mode_.has_value()) {
103 ESP_LOGV(TAG,
" Away: %s",
104 (this->
state_ & WATER_HEATER_STATE_AWAY) ? LOG_STR_LITERAL(
"YES") : LOG_STR_LITERAL(
"NO"));
107 ESP_LOGV(TAG,
" On: %s", (this->
state_ & WATER_HEATER_STATE_ON) ? LOG_STR_LITERAL(
"YES") : LOG_STR_LITERAL(
"NO"));
114 if (this->
mode_.has_value()) {
115 if (!traits.supports_mode(*this->mode_)) {
117 static_cast<uint32_t>(*this->mode_));
122 if (traits.get_supports_two_point_target_temperature()) {
123 ESP_LOGW(TAG,
"'%s' - Cannot set target temperature for device with two-point target temperature",
127 this->target_temperature_ > traits.get_max_temperature()) {
128 ESP_LOGW(TAG,
"'%s' - Target temperature %.1f is out of range [%.1f - %.1f]", this->
parent_->
get_name().
c_str(),
129 this->target_temperature_, traits.get_min_temperature(), traits.get_max_temperature());
131 std::max(traits.get_min_temperature(), std::min(this->target_temperature_, traits.get_max_temperature()));
135 if (!traits.get_supports_two_point_target_temperature()) {
136 ESP_LOGW(TAG,
"'%s' - Cannot set low/high target temperature", this->
parent_->
get_name().
c_str());
143 ESP_LOGW(TAG,
"'%s' - Target temperature low %.2f must be less than high %.2f", this->
parent_->
get_name().
c_str(),
144 this->target_temperature_low_, this->target_temperature_high_);
149 if (!traits.get_supports_away_mode()) {
153 this->
state_ &= ~WATER_HEATER_STATE_AWAY;
158 this->
state_ &= ~WATER_HEATER_STATE_ON;
179 ESP_LOGV(TAG,
" Away: YES");
185#if defined(USE_WATER_HEATER) && defined(USE_CONTROLLER_REGISTRY)
186 ControllerRegistry::notify_water_heater_update(
this);
197 saved.state = this->
state_;
209 call.set_mode(recovered.mode);
211 call.set_target_temperature_low(recovered.target_temperature_low);
212 call.set_target_temperature_high(recovered.target_temperature_high);
214 call.set_target_temperature(recovered.target_temperature);
223#ifdef USE_WATER_HEATER_VISUAL_OVERRIDES
239PROGMEM_STRING_TABLE(WaterHeaterModeStrings,
"OFF",
"ECO",
"ELECTRIC",
"PERFORMANCE",
"HIGH_DEMAND",
"HEAT_PUMP",
"GAS",
243 return WaterHeaterModeStrings::get_log_str(
static_cast<uint8_t
>(
mode), WaterHeaterModeStrings::LAST_INDEX);
249 " Min Temperature: %.1f°C\n"
250 " Max Temperature: %.1f°C\n"
251 " Temperature Step: %.1f",
254 ESP_LOGCONFIG(tag,
" Supports Two-Point Target Temperature: YES");
257 ESP_LOGCONFIG(tag,
" Supports Away Mode: YES");
260 ESP_LOGCONFIG(tag,
" Supports On/Off: YES");
263 ESP_LOGCONFIG(tag,
" Supported Modes:");
BedjetMode mode
BedJet operating mode.
const StringRef & get_name() const
ESPPreferenceObject make_entity_preference(uint32_t version=0)
Create a preference object for storing this entity's state/settings.
constexpr bool empty() const
Check if the set is empty.
constexpr const char * c_str() const
WaterHeaterCall & set_away(bool away)
WaterHeaterCall & set_target_temperature_high(float temperature)
WaterHeaterCall & set_mode(WaterHeaterMode mode)
WaterHeaterCall & set_target_temperature_low(float temperature)
WaterHeaterCall & set_on(bool on)
float target_temperature_low_
float target_temperature_high_
float target_temperature_
optional< WaterHeaterMode > mode_
WaterHeaterCall & set_target_temperature(float temperature)
float visual_target_temperature_step_override_
ESPPreferenceObject pref_
virtual void publish_state()
virtual void control(const WaterHeaterCall &call)=0
float visual_max_temperature_override_
float target_temperature_low_
float visual_min_temperature_override_
optional< WaterHeaterCall > restore_state_()
Restore the state of the water heater, call this from your setup() method.
virtual WaterHeaterCallInternal make_call()=0
float target_temperature_
float current_temperature_
void dump_traits_(const char *tag)
Log the traits of this water heater for dump_config().
virtual WaterHeaterTraits get_traits()
float target_temperature_high_
virtual WaterHeaterTraits traits()=0
bool get_supports_two_point_target_temperature() const
float get_target_temperature_step() const
const WaterHeaterModeMask & get_supported_modes() const
float get_min_temperature() const
void set_min_temperature(float min_temperature)
bool get_supports_away_mode() const
bool has_feature_flags(uint32_t flags) const
void set_target_temperature_step(float target_temperature_step)
float get_max_temperature() const
void set_max_temperature(float max_temperature)
PROGMEM_STRING_TABLE(WaterHeaterModeStrings, "OFF", "ECO", "ELECTRIC", "PERFORMANCE", "HIGH_DEMAND", "HEAT_PUMP", "GAS", "UNKNOWN")
void log_water_heater(const char *tag, const char *prefix, const char *type, WaterHeater *obj)
@ WATER_HEATER_MODE_ELECTRIC
@ WATER_HEATER_MODE_HIGH_DEMAND
@ WATER_HEATER_MODE_HEAT_PUMP
@ WATER_HEATER_MODE_PERFORMANCE
@ WATER_HEATER_STATE_ON
Water heater is on (not in standby)
@ WATER_HEATER_STATE_AWAY
Away/vacation mode is currently active.
@ WATER_HEATER_SUPPORTS_ON_OFF
The water heater can be turned on/off.
const LogString * water_heater_mode_to_string(WaterHeaterMode mode)
Convert the given WaterHeaterMode to a human-readable string for logging.