15 #define LOG_VALVE(prefix, type, obj) \ 16 if ((obj) != nullptr) { \ 17 ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \ 18 auto traits_ = (obj)->get_traits(); \ 19 if (traits_.get_is_assumed_state()) { \ 20 ESP_LOGCONFIG(TAG, "%s Assumed State: YES", prefix); \ 22 if (!(obj)->get_device_class().empty()) { \ 23 ESP_LOGCONFIG(TAG, "%s Device Class: '%s'", prefix, (obj)->get_device_class().c_str()); \ 121 void add_on_state_callback(std::function<
void()> &&f);
130 void publish_state(
bool save =
true);
135 bool is_fully_open()
const;
137 bool is_fully_closed()
const;
142 virtual void control(
const ValveCall &call) = 0;
ValveCall & set_command(const char *command)
Set the command as a string, "STOP", "OPEN", "CLOSE", "TOGGLE".
ValveCall & set_command_open()
Set the command to open the valve.
ValveOperation
Enum encoding the current operation of a valve.
float position
The position of the valve from 0.0 (fully closed) to 1.0 (fully open).
const optional< bool > & get_toggle() const
Struct used to store the restored state of a valve.
ValveCall & set_command_stop()
Set the command to stop the valve.
The valve is currently opening.
ValveCall & set_command_toggle()
Set the command to toggle the valve.
ValveCall & set_command_close()
Set the command to close the valve.
ValveCall to_call(Valve *valve)
Convert this struct to a valve call that can be performed.
The valve is currently idle (not moving)
The valve is currently closing.
void perform()
Perform the valve call.
void apply(Valve *valve)
Apply these settings to the valve.
ValveCall & set_stop(bool stop)
Set whether this valve call should stop the valve.
const char * valve_operation_to_str(ValveOperation op)
enum esphome::valve::ValveOperation __attribute__
const optional< float > & get_position() const
Implementation of SPI Controller mode.
Base class for all valve devices.
ValveCall & set_position(float position)
Set the call to a certain target position.
optional< float > position_