9 static const char *
const TAG =
"template.cover";
12 : open_trigger_(new
Trigger<>()),
15 toggle_trigger_(new
Trigger<>()),
16 position_trigger_(new
Trigger<float>()),
17 tilt_trigger_(new
Trigger<float>()) {}
19 ESP_LOGCONFIG(TAG,
"Setting up template cover '%s'...", this->
name_.
c_str());
25 if (restore.has_value())
31 if (restore.has_value()) {
32 restore->to_call(
this).perform();
44 auto pos =
clamp(*s, 0.0f, 1.0f);
51 if (this->
tilt_f_.has_value()) {
120 traits.set_supports_stop(this->
has_stop_);
123 traits.set_supports_tilt(this->
has_tilt_);
float get_setup_priority() const override
void publish_state(bool save=true)
Publish the current state of the cover.
Trigger< float > * tilt_trigger_
void set_has_toggle(bool has_toggle)
void set_has_position(bool has_position)
Trigger * toggle_trigger_
void dump_config() override
Trigger * get_toggle_trigger() const
Trigger< float > * position_trigger_
cover::CoverTraits get_traits() override
optional< CoverRestoreState > restore_state_()
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
float tilt
The current tilt value of the cover from 0.0 to 1.0.
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
void set_has_tilt(bool has_tilt)
void set_tilt_lambda(std::function< optional< float >()> &&tilt_f)
void set_optimistic(bool optimistic)
void control(const cover::CoverCall &call) override
const optional< bool > & get_toggle() const
void set_state_lambda(std::function< optional< float >()> &&f)
TemplateCoverRestoreMode restore_mode_
Trigger< float > * get_position_trigger() const
Trigger * prev_command_trigger_
void set_assumed_state(bool assumed_state)
constexpr const char * c_str() const
optional< std::function< optional< float >)> > state_f_
float position
The position of the cover from 0.0 (fully closed) to 1.0 (fully open).
Trigger * get_close_trigger() const
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Trigger * get_stop_trigger() const
void stop_prev_trigger_()
optional< std::function< optional< float >)> > tilt_f_
Trigger< float > * get_tilt_trigger() const
void set_has_stop(bool has_stop)
Implementation of SPI Controller mode.
const optional< float > & get_tilt() const
void stop_action()
Stop any action connected to this trigger.
Trigger * get_open_trigger() const
const optional< float > & get_position() const