9static 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_));
74 if (
call.get_stop()) {
87 auto pos = *
call.get_position();
111 traits.set_supports_stop(this->
has_stop_);
constexpr const char * c_str() const
void stop_action()
Stop any action connected to this trigger.
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
void set_optimistic(bool optimistic)
Trigger * toggle_trigger_
float get_setup_priority() const override
Trigger * get_stop_trigger() const
optional< std::function< optional< float >()> > state_f_
void set_has_stop(bool has_stop)
void set_state_lambda(std::function< optional< float >()> &&f)
Trigger< float > * position_trigger_
void set_has_position(bool has_position)
void set_assumed_state(bool assumed_state)
void stop_prev_trigger_()
Trigger * get_close_trigger() const
Trigger * get_toggle_trigger() const
valve::ValveTraits get_traits() override
void control(const valve::ValveCall &call) override
TemplateValveRestoreMode restore_mode_
void dump_config() override
Trigger< float > * get_position_trigger() const
void set_has_toggle(bool has_toggle)
Trigger * prev_command_trigger_
Trigger * get_open_trigger() const
const optional< bool > & get_toggle() const
const optional< float > & get_position() const
optional< ValveRestoreState > restore_state_()
void publish_state(bool save=true)
Publish the current state of the valve.
float position
The position of the valve from 0.0 (fully closed) to 1.0 (fully open).
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Providing packet encoding functions for exchanging data with a remote host.
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)