27 if (
len == 3 && ESPHOME_strncasecmp_P(
mode, ESPHOME_PSTR(
"OFF"), 3) == 0) {
29 }
else if (len == 3 && ESPHOME_strncasecmp_P(
mode, ESPHOME_PSTR(
"ECO"), 3) == 0) {
31 }
else if (len == 8 && ESPHOME_strncasecmp_P(
mode, ESPHOME_PSTR(
"ELECTRIC"), 8) == 0) {
33 }
else if (len == 11 && ESPHOME_strncasecmp_P(
mode, ESPHOME_PSTR(
"PERFORMANCE"), 11) == 0) {
35 }
else if (len == 11 && ESPHOME_strncasecmp_P(
mode, ESPHOME_PSTR(
"HIGH_DEMAND"), 11) == 0) {
37 }
else if (len == 9 && ESPHOME_strncasecmp_P(
mode, ESPHOME_PSTR(
"HEAT_PUMP"), 9) == 0) {
39 }
else if (len == 3 && ESPHOME_strncasecmp_P(
mode, ESPHOME_PSTR(
"GAS"), 3) == 0) {
77 if (this->
mode_.has_value()) {
90 ESP_LOGV(TAG,
" Away: %s",
91 (this->
state_ & WATER_HEATER_STATE_AWAY) ? LOG_STR_LITERAL(
"YES") : LOG_STR_LITERAL(
"NO"));
94 ESP_LOGV(TAG,
" On: %s", (this->
state_ & WATER_HEATER_STATE_ON) ? LOG_STR_LITERAL(
"YES") : LOG_STR_LITERAL(
"NO"));
101 if (this->
mode_.has_value()) {
102 if (!traits.supports_mode(*this->mode_)) {
103 ESP_LOGW(TAG,
"'%s' - Mode %" PRIu32
" not supported", LOG_STR_ARG(this->
parent_->
get_log_name()),
104 static_cast<uint32_t>(*this->mode_));
109 if (traits.get_supports_two_point_target_temperature()) {
110 ESP_LOGW(TAG,
"'%s' - Cannot set target temperature for device with two-point target temperature",
114 this->target_temperature_ > traits.get_max_temperature()) {
115 ESP_LOGW(TAG,
"'%s' - Target temperature %.1f is out of range [%.1f - %.1f]",
116 LOG_STR_ARG(this->
parent_->
get_log_name()), this->target_temperature_, traits.get_min_temperature(),
117 traits.get_max_temperature());
119 std::max(traits.get_min_temperature(), std::min(this->target_temperature_, traits.get_max_temperature()));
123 if (!traits.get_supports_two_point_target_temperature()) {
124 ESP_LOGW(TAG,
"'%s' - Cannot set low/high target temperature", LOG_STR_ARG(this->
parent_->
get_log_name()));
131 ESP_LOGW(TAG,
"'%s' - Target temperature low %.2f must be less than high %.2f",
133 this->target_temperature_high_);
138 if (!traits.get_supports_away_mode()) {
140 ESP_LOGW(TAG,
"'%s' - Away mode not supported", LOG_STR_ARG(this->
parent_->
get_log_name()));
142 this->
state_ &= ~WATER_HEATER_STATE_AWAY;
147 this->
state_ &= ~WATER_HEATER_STATE_ON;
169 ESP_LOGV(TAG,
" Away: YES");
175#if defined(USE_WATER_HEATER) && defined(USE_CONTROLLER_REGISTRY)
176 ControllerRegistry::notify_water_heater_update(
this);
187 saved.state = this->
state_;
199 call.set_mode(recovered.mode);
201 call.set_target_temperature_low(recovered.target_temperature_low);
202 call.set_target_temperature_high(recovered.target_temperature_high);
204 call.set_target_temperature(recovered.target_temperature);
213#ifdef USE_WATER_HEATER_VISUAL_OVERRIDES
229PROGMEM_STRING_TABLE(WaterHeaterModeStrings,
"OFF",
"ECO",
"ELECTRIC",
"PERFORMANCE",
"HIGH_DEMAND",
"HEAT_PUMP",
"GAS",
233 return WaterHeaterModeStrings::get_log_str(
static_cast<uint8_t
>(
mode), WaterHeaterModeStrings::LAST_INDEX);
239 " Min Temperature: %.1f°C\n"
240 " Max Temperature: %.1f°C\n"
241 " Temperature Step: %.1f",
244 ESP_LOGCONFIG(tag,
" Supports Two-Point Target Temperature: YES");
247 ESP_LOGCONFIG(tag,
" Supports Away Mode: YES");
250 ESP_LOGCONFIG(tag,
" Supports On/Off: YES");
253 ESP_LOGCONFIG(tag,
" Supported Modes:");
BedjetMode mode
BedJet operating mode.
const LogString * get_log_name() const
Get the name for a "%s" log argument (LOG_STR_ARG).
ESPPreferenceObject make_entity_preference(uint32_t version=0)
Create a preference object for storing this entity's state/settings.
void set_has_state(bool state)
constexpr bool empty() const
Check if the set is empty.
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")
@ 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.
ESPHOME_LOG_TAG(TAG, "water_heater")
ESPHOME_ALWAYS_INLINE constexpr void assign_bits(T &value, std::type_identity_t< T > mask, bool on)
Set the bits of mask in value when on is true, clear them otherwise.