ESPHome 2026.9.0-dev
Loading...
Searching...
No Matches
esphome::tuya::TuyaWaterHeater Class Referencefinal

#include <tuya_water_heater.h>

Inheritance diagram for esphome::tuya::TuyaWaterHeater:
esphome::water_heater::WaterHeater esphome::Component esphome::EntityBase

Public Member Functions

void setup () override
 
void dump_config () override
 
void set_tuya_parent (Tuya *parent)
 
void set_switch_id (uint8_t switch_id)
 
void set_target_temperature_id (uint8_t target_temperature_id)
 
void set_current_temperature_id (uint8_t current_temperature_id)
 
void set_target_temperature_multiplier (float multiplier)
 
void set_current_temperature_multiplier (float multiplier)
 
void set_mode_id (uint8_t mode_id)
 
void set_eco_value (uint8_t value)
 
void set_electric_value (uint8_t value)
 
void set_performance_value (uint8_t value)
 
void set_high_demand_value (uint8_t value)
 
void set_heat_pump_value (uint8_t value)
 
void set_gas_value (uint8_t value)
 
void set_supported_modes (const std::initializer_list< water_heater::WaterHeaterMode > &modes)
 
water_heater::WaterHeaterCallInternal make_call () override
 
- Public Member Functions inherited from esphome::water_heater::WaterHeater
WaterHeaterMode get_mode () const
 
float get_current_temperature () const
 
float get_target_temperature () const
 
float get_target_temperature_low () const
 
float get_target_temperature_high () const
 
uint32_t get_state () const
 Get the current state flags bitmask.
 
bool is_away () const
 Check if away mode is currently active.
 
bool is_on () const
 Check if the water heater is on.
 
void set_current_temperature (float current_temperature)
 
virtual void publish_state ()
 
virtual WaterHeaterTraits get_traits ()
 
void set_visual_min_temperature_override (float min_temperature_override)
 
void set_visual_max_temperature_override (float max_temperature_override)
 
void set_visual_target_temperature_step_override (float visual_target_temperature_step_override)
 
- Public Member Functions inherited from esphome::EntityBase
const StringRefget_name () const
 
bool has_own_name () const
 
uint32_t get_object_id_hash () const
 
StringRef get_object_id_to (std::span< char, OBJECT_ID_MAX_LEN > buf) const
 Get object_id with zero heap allocation For static case: returns StringRef to internal storage (buffer unused) For dynamic case: formats into buffer and returns StringRef to buffer.
 
size_t write_object_id_to (char *buf, size_t buf_size) const
 Write object_id directly to buffer, returns length written (excluding null) Useful for building compound strings without intermediate buffer.
 
bool is_internal () const
 
 ESPDEPRECATED ("set_internal() is undefined behavior at runtime — components and Home Assistant are NOT " "notified. Use the 'internal:' YAML key instead. Will be removed in 2027.3.0.", "2026.3.0") void set_internal(bool internal)
 
bool is_disabled_by_default () const
 
EntityCategory get_entity_category () const
 
const char * get_device_class_to (std::span< char, MAX_DEVICE_CLASS_LENGTH > buffer) const
 
StringRef get_unit_of_measurement_ref () const
 
const char * get_icon_to (std::span< char, MAX_ICON_LENGTH > buffer) const
 
uint32_t get_device_id () const
 
Deviceget_device () const
 
bool has_state () const
 
void set_has_state (bool state)
 
 ESPDEPRECATED ("Use make_entity_preference<T>() instead, or preferences won't be migrated. " "See https://github.com/esphome/backlog/issues/85. Will be removed in 2027.1.0.", "2026.7.0") uint32_t get_preference_hash()
 Get a unique hash for storing preferences/settings for this entity.
 
template<typename T >
ESPPreferenceObject make_entity_preference (uint32_t version=0)
 Create a preference object for storing this entity's state/settings.
 
- Public Member Functions inherited from esphome::Component
virtual void loop ()
 This method will be called repeatedly.
 
virtual float get_setup_priority () const
 priority of setup().
 
float get_actual_setup_priority () const
 
void set_setup_priority (float priority)
 
void call ()
 
virtual void on_shutdown ()
 
virtual void on_safe_shutdown ()
 
virtual bool teardown ()
 Called during teardown to allow component to gracefully finish operations.
 
virtual void on_powerdown ()
 Called after teardown is complete to power down hardware.
 
uint8_t get_component_state () const
 
void reset_to_construction_state ()
 Reset this component back to the construction state to allow setup to run again.
 
bool is_in_loop_state () const
 Check if this component has completed setup and is in the loop state.
 
bool is_idle () const
 Check if this component is idle.
 
void mark_failed ()
 Mark this component as failed.
 
void mark_failed (const LogString *message)
 
void disable_loop ()
 Disable this component's loop.
 
void enable_loop ()
 Enable this component's loop.
 
void enable_loop_soon_any_context ()
 Thread and ISR-safe version of enable_loop() that can be called from any context.
 
bool is_failed () const
 
bool is_ready () const
 
virtual bool can_proceed ()
 
bool status_has_warning () const
 
bool status_has_error () const
 
void status_set_warning ()
 
void status_set_warning (const char *message)
 
void status_set_warning (const LogString *message)
 
void status_set_error ()
 
void status_set_error (const LogString *message)
 
void status_clear_warning ()
 
void status_clear_error ()
 
void status_momentary_warning (const char *name, uint32_t length=5000)
 Set warning status flag and automatically clear it after a timeout.
 
void status_momentary_error (const char *name, uint32_t length=5000)
 Set error status flag and automatically clear it after a timeout.
 
bool has_overridden_loop () const
 
const LogString * get_component_log_str () const ESPHOME_ALWAYS_INLINE
 Get the integration where this component was declared as a LogString for logging.
 
bool should_warn_of_blocking (uint32_t blocking_time, uint32_t &threshold_ms_out)
 

Protected Member Functions

void control (const water_heater::WaterHeaterCall &call) override
 
water_heater::WaterHeaterTraits traits () override
 
bool mode_from_value_ (uint8_t value, water_heater::WaterHeaterMode &mode) const
 Map a Tuya mode datapoint enum value to a WaterHeaterMode.
 
bool value_from_mode_ (water_heater::WaterHeaterMode mode, uint8_t &value) const
 Map a WaterHeaterMode to its configured Tuya enum value. Returns true when a mapping exists.
 
water_heater::WaterHeaterMode default_on_mode_ () const
 The mode to show when the heater is on but no mode datapoint value is known yet: the last reported mode, else the first configured supported non-OFF mode, else ELECTRIC.
 
- Protected Member Functions inherited from esphome::water_heater::WaterHeater
void dump_traits_ (const char *tag)
 Log the traits of this water heater for dump_config().
 
optional< WaterHeaterCallrestore_state_ ()
 Restore the state of the water heater, call this from your setup() method.
 
void set_mode_ (WaterHeaterMode mode)
 Set the mode of the water heater. Should only be called from control().
 
void set_target_temperature_ (float target_temperature)
 Set the target temperature of the water heater. Should only be called from control().
 
void set_target_temperature_low_ (float target_temperature_low)
 Set the low target temperature (for two-point control). Should only be called from control().
 
void set_target_temperature_high_ (float target_temperature_high)
 Set the high target temperature (for two-point control). Should only be called from control().
 
void set_state_ (uint32_t state)
 Set the state flags. Should only be called from control().
 
void set_state_flag_ (uint32_t flag, bool value)
 Set or clear a state flag. Should only be called from control().
 
- Protected Member Functions inherited from esphome::EntityBase
friend void::setup ()
 
friend void::original_setup ()
 
void configure_entity_ (const char *name, uint32_t object_id_hash, uint32_t entity_fields)
 Combined entity setup from codegen: set name, object_id hash, entity string indices, and flags.
 
void set_device_ (Device *device)
 
ESPPreferenceObject make_entity_preference_ (size_t size, uint32_t version)
 Non-template helper for make_entity_preference() to avoid code bloat.
 
void calc_object_id_ ()
 
- Protected Member Functions inherited from esphome::Component
friend void::setup ()
 
friend void::original_setup ()
 
void set_component_source_ (uint8_t index)
 Set where this component was loaded from for some debug messages.
 
virtual void call_setup ()
 
void call_dump_config_ ()
 
void enable_loop_slow_path_ ()
 
void set_component_state_ (uint8_t state)
 Helper to set component state (clears state bits and sets new state)
 
bool set_status_flag_ (uint8_t flag)
 Helper to set a status LED flag on both this component and the app.
 
void set_interval (const char *name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a const char* name.
 
void set_interval (uint32_t id, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a numeric ID (zero heap allocation).
 
void set_interval (InternalSchedulerID id, uint32_t interval, std::function< void()> &&f)
 
void set_interval (uint32_t interval, std::function< void()> &&f)
 
bool cancel_interval (const char *name)
 Cancel an interval function.
 
bool cancel_interval (uint32_t id)
 
bool cancel_interval (InternalSchedulerID id)
 
void set_timeout (const char *name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a const char* name.
 
void set_timeout (uint32_t id, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a numeric ID (zero heap allocation).
 
void set_timeout (InternalSchedulerID id, uint32_t timeout, std::function< void()> &&f)
 
void set_timeout (uint32_t timeout, std::function< void()> &&f)
 
bool cancel_timeout (const char *name)
 Cancel a timeout function.
 
bool cancel_timeout (uint32_t id)
 
bool cancel_timeout (InternalSchedulerID id)
 
void defer (const char *name, std::function< void()> &&f)
 Defer a callback to the next loop() call with a const char* name.
 
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call.
 
void defer (uint32_t id, std::function< void()> &&f)
 Defer a callback with a numeric ID (zero heap allocation)
 
bool cancel_defer (const char *name)
 Cancel a defer callback using the specified name, name must not be empty.
 
bool cancel_defer (uint32_t id)
 
void status_clear_warning_slow_path_ ()
 
void status_clear_error_slow_path_ ()
 

Protected Attributes

Tuyaparent_ {nullptr}
 
optional< uint8_t > switch_id_ {}
 
optional< uint8_t > target_temperature_id_ {}
 
optional< uint8_t > current_temperature_id_ {}
 
optional< uint8_t > mode_id_ {}
 
optional< uint8_t > eco_value_ {}
 
optional< uint8_t > electric_value_ {}
 
optional< uint8_t > performance_value_ {}
 
optional< uint8_t > high_demand_value_ {}
 
optional< uint8_t > heat_pump_value_ {}
 
optional< uint8_t > gas_value_ {}
 
float target_temperature_multiplier_ {1.0f}
 
float current_temperature_multiplier_ {1.0f}
 
water_heater::WaterHeaterModeMask supported_modes_
 
optional< water_heater::WaterHeaterModelast_reported_mode_ {}
 Last non-OFF mode reported by the mode datapoint, applied when the heater turns on.
 
bool is_on_ {false}
 
- Protected Attributes inherited from esphome::water_heater::WaterHeater
WaterHeaterMode mode_ {WATER_HEATER_MODE_OFF}
 
float current_temperature_ {NAN}
 
float target_temperature_ {NAN}
 
float target_temperature_low_ {NAN}
 
float target_temperature_high_ {NAN}
 
uint32_t state_ {0}
 
float visual_min_temperature_override_ {NAN}
 
float visual_max_temperature_override_ {NAN}
 
float visual_target_temperature_step_override_ {NAN}
 
ESPPreferenceObject pref_
 
- Protected Attributes inherited from esphome::EntityBase
StringRef name_
 
uint32_t object_id_hash_ {}
 
Devicedevice_ {}
 
struct esphome::EntityBase::EntityFlags flags_
 
uint8_t device_class_idx_ {}
 
uint8_t uom_idx_ {}
 
uint8_t icon_idx_ {}
 
- Protected Attributes inherited from esphome::Component
uint8_t component_source_index_ {0}
 Index into component source PROGMEM lookup table (0 = not set)
 
uint8_t warn_if_blocking_over_ {WARN_IF_BLOCKING_OVER_CS}
 Warn threshold in centiseconds (max 2550ms)
 
uint8_t component_state_ {0x00}
 State of this component - each bit has a purpose: Bits 0-2: Component state (0x00=CONSTRUCTION, 0x01=SETUP, 0x02=LOOP, 0x03=FAILED, 0x04=LOOP_DONE) Bit 3: STATUS_LED_WARNING Bit 4: STATUS_LED_ERROR Bit 5: Has overridden loop() (set at registration time) Bits 6-7: Unused - reserved for future expansion.
 
volatile bool pending_enable_loop_ {false}
 ISR-safe flag for enable_loop_soon_any_context.
 
ComponentRuntimeStats runtime_stats_
 

Detailed Description

Definition at line 9 of file tuya_water_heater.h.

Member Function Documentation

◆ control()

void esphome::tuya::TuyaWaterHeater::control ( const water_heater::WaterHeaterCall & call)
overrideprotectedvirtual

Implements esphome::water_heater::WaterHeater.

Definition at line 66 of file tuya_water_heater.cpp.

◆ default_on_mode_()

water_heater::WaterHeaterMode esphome::tuya::TuyaWaterHeater::default_on_mode_ ( ) const
protected

The mode to show when the heater is on but no mode datapoint value is known yet: the last reported mode, else the first configured supported non-OFF mode, else ELECTRIC.

Definition at line 167 of file tuya_water_heater.cpp.

◆ dump_config()

void esphome::tuya::TuyaWaterHeater::dump_config ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 178 of file tuya_water_heater.cpp.

◆ make_call()

water_heater::WaterHeaterCallInternal esphome::tuya::TuyaWaterHeater::make_call ( )
overridevirtual

Implements esphome::water_heater::WaterHeater.

Definition at line 62 of file tuya_water_heater.cpp.

◆ mode_from_value_()

bool esphome::tuya::TuyaWaterHeater::mode_from_value_ ( uint8_t value,
water_heater::WaterHeaterMode & mode ) const
protected

Map a Tuya mode datapoint enum value to a WaterHeaterMode.

Returns true when a mapping exists, writing the result to mode.

Definition at line 117 of file tuya_water_heater.cpp.

◆ set_current_temperature_id()

void esphome::tuya::TuyaWaterHeater::set_current_temperature_id ( uint8_t current_temperature_id)
inline

Definition at line 20 of file tuya_water_heater.h.

◆ set_current_temperature_multiplier()

void esphome::tuya::TuyaWaterHeater::set_current_temperature_multiplier ( float multiplier)
inline

Definition at line 24 of file tuya_water_heater.h.

◆ set_eco_value()

void esphome::tuya::TuyaWaterHeater::set_eco_value ( uint8_t value)
inline

Definition at line 27 of file tuya_water_heater.h.

◆ set_electric_value()

void esphome::tuya::TuyaWaterHeater::set_electric_value ( uint8_t value)
inline

Definition at line 28 of file tuya_water_heater.h.

◆ set_gas_value()

void esphome::tuya::TuyaWaterHeater::set_gas_value ( uint8_t value)
inline

Definition at line 32 of file tuya_water_heater.h.

◆ set_heat_pump_value()

void esphome::tuya::TuyaWaterHeater::set_heat_pump_value ( uint8_t value)
inline

Definition at line 31 of file tuya_water_heater.h.

◆ set_high_demand_value()

void esphome::tuya::TuyaWaterHeater::set_high_demand_value ( uint8_t value)
inline

Definition at line 30 of file tuya_water_heater.h.

◆ set_mode_id()

void esphome::tuya::TuyaWaterHeater::set_mode_id ( uint8_t mode_id)
inline

Definition at line 26 of file tuya_water_heater.h.

◆ set_performance_value()

void esphome::tuya::TuyaWaterHeater::set_performance_value ( uint8_t value)
inline

Definition at line 29 of file tuya_water_heater.h.

◆ set_supported_modes()

void esphome::tuya::TuyaWaterHeater::set_supported_modes ( const std::initializer_list< water_heater::WaterHeaterMode > & modes)
inline

Definition at line 34 of file tuya_water_heater.h.

◆ set_switch_id()

void esphome::tuya::TuyaWaterHeater::set_switch_id ( uint8_t switch_id)
inline

Definition at line 16 of file tuya_water_heater.h.

◆ set_target_temperature_id()

void esphome::tuya::TuyaWaterHeater::set_target_temperature_id ( uint8_t target_temperature_id)
inline

Definition at line 17 of file tuya_water_heater.h.

◆ set_target_temperature_multiplier()

void esphome::tuya::TuyaWaterHeater::set_target_temperature_multiplier ( float multiplier)
inline

Definition at line 23 of file tuya_water_heater.h.

◆ set_tuya_parent()

void esphome::tuya::TuyaWaterHeater::set_tuya_parent ( Tuya * parent)
inline

Definition at line 14 of file tuya_water_heater.h.

◆ setup()

void esphome::tuya::TuyaWaterHeater::setup ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 8 of file tuya_water_heater.cpp.

◆ traits()

water_heater::WaterHeaterTraits esphome::tuya::TuyaWaterHeater::traits ( )
overrideprotectedvirtual

Implements esphome::water_heater::WaterHeater.

Definition at line 100 of file tuya_water_heater.cpp.

◆ value_from_mode_()

bool esphome::tuya::TuyaWaterHeater::value_from_mode_ ( water_heater::WaterHeaterMode mode,
uint8_t & value ) const
protected

Map a WaterHeaterMode to its configured Tuya enum value. Returns true when a mapping exists.

Definition at line 136 of file tuya_water_heater.cpp.

Field Documentation

◆ current_temperature_id_

optional<uint8_t> esphome::tuya::TuyaWaterHeater::current_temperature_id_ {}
protected

Definition at line 53 of file tuya_water_heater.h.

◆ current_temperature_multiplier_

float esphome::tuya::TuyaWaterHeater::current_temperature_multiplier_ {1.0f}
protected

Definition at line 62 of file tuya_water_heater.h.

◆ eco_value_

optional<uint8_t> esphome::tuya::TuyaWaterHeater::eco_value_ {}
protected

Definition at line 55 of file tuya_water_heater.h.

◆ electric_value_

optional<uint8_t> esphome::tuya::TuyaWaterHeater::electric_value_ {}
protected

Definition at line 56 of file tuya_water_heater.h.

◆ gas_value_

optional<uint8_t> esphome::tuya::TuyaWaterHeater::gas_value_ {}
protected

Definition at line 60 of file tuya_water_heater.h.

◆ heat_pump_value_

optional<uint8_t> esphome::tuya::TuyaWaterHeater::heat_pump_value_ {}
protected

Definition at line 59 of file tuya_water_heater.h.

◆ high_demand_value_

optional<uint8_t> esphome::tuya::TuyaWaterHeater::high_demand_value_ {}
protected

Definition at line 58 of file tuya_water_heater.h.

◆ is_on_

bool esphome::tuya::TuyaWaterHeater::is_on_ {false}
protected

Definition at line 66 of file tuya_water_heater.h.

◆ last_reported_mode_

optional<water_heater::WaterHeaterMode> esphome::tuya::TuyaWaterHeater::last_reported_mode_ {}
protected

Last non-OFF mode reported by the mode datapoint, applied when the heater turns on.

Definition at line 65 of file tuya_water_heater.h.

◆ mode_id_

optional<uint8_t> esphome::tuya::TuyaWaterHeater::mode_id_ {}
protected

Definition at line 54 of file tuya_water_heater.h.

◆ parent_

Tuya* esphome::tuya::TuyaWaterHeater::parent_ {nullptr}
protected

Definition at line 50 of file tuya_water_heater.h.

◆ performance_value_

optional<uint8_t> esphome::tuya::TuyaWaterHeater::performance_value_ {}
protected

Definition at line 57 of file tuya_water_heater.h.

◆ supported_modes_

water_heater::WaterHeaterModeMask esphome::tuya::TuyaWaterHeater::supported_modes_
protected

Definition at line 63 of file tuya_water_heater.h.

◆ switch_id_

optional<uint8_t> esphome::tuya::TuyaWaterHeater::switch_id_ {}
protected

Definition at line 51 of file tuya_water_heater.h.

◆ target_temperature_id_

optional<uint8_t> esphome::tuya::TuyaWaterHeater::target_temperature_id_ {}
protected

Definition at line 52 of file tuya_water_heater.h.

◆ target_temperature_multiplier_

float esphome::tuya::TuyaWaterHeater::target_temperature_multiplier_ {1.0f}
protected

Definition at line 61 of file tuya_water_heater.h.


The documentation for this class was generated from the following files: