9 static const char *
const TAG =
"template.valve";
12 : open_trigger_(new
Trigger<>()),
15 toggle_trigger_(new
Trigger<>()),
16 position_trigger_(new
Trigger<float>()) {}
19 ESP_LOGCONFIG(TAG,
"Setting up template valve '%s'...", this->
name_.
c_str());
25 if (restore.has_value())
31 if (restore.has_value()) {
32 restore->to_call(
this).perform();
45 auto pos =
clamp(*s, 0.0f, 1.0f);
68 LOG_VALVE(
"",
"Template Valve",
this);
69 ESP_LOGCONFIG(TAG,
" Has position: %s", YESNO(this->
has_position_));
70 ESP_LOGCONFIG(TAG,
" Optimistic: %s", YESNO(this->
optimistic_));
111 traits.set_supports_stop(this->
has_stop_);
void set_has_position(bool has_position)
Trigger * get_close_trigger() const
float position
The position of the valve from 0.0 (fully closed) to 1.0 (fully open).
void set_has_toggle(bool has_toggle)
Trigger * get_stop_trigger() const
void set_state_lambda(std::function< optional< float >()> &&f)
void set_has_stop(bool has_stop)
void control(const valve::ValveCall &call) override
const optional< bool > & get_toggle() const
Trigger * get_open_trigger() const
Trigger * prev_command_trigger_
float get_setup_priority() const override
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
void dump_config() override
void set_optimistic(bool optimistic)
optional< std::function< optional< float >)> > state_f_
Trigger< float > * position_trigger_
Trigger * get_toggle_trigger() const
Trigger * toggle_trigger_
Trigger< float > * get_position_trigger() const
optional< ValveRestoreState > restore_state_()
constexpr const char * c_str() const
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
valve::ValveTraits get_traits() override
const optional< float > & get_position() const
void stop_prev_trigger_()
Implementation of SPI Controller mode.
void publish_state(bool save=true)
Publish the current state of the valve.
TemplateValveRestoreMode restore_mode_
void stop_action()
Stop any action connected to this trigger.
void set_assumed_state(bool assumed_state)