9static 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>()) {}
24 if (restore.has_value())
30 if (restore.has_value()) {
31 restore->to_call(
this).perform();
44 auto pos = clamp(*s, 0.0f, 1.0f);
52 if (
tilt.has_value()) {
53 auto tilt_val = clamp(*
tilt, 0.0f, 1.0f);
54 if (tilt_val != this->
tilt) {
55 this->
tilt = tilt_val;
72 if (
call.get_stop()) {
85 auto pos = *
call.get_position();
103 if (
call.get_tilt().has_value()) {
117 traits.set_supports_stop(this->
has_stop_);
120 traits.set_supports_tilt(this->
has_tilt_);
void disable_loop()
Disable this component's loop.
bool has_value() const
Check if a lambda is set.
void trigger(const Ts &...x)
Inform the parent automation that the event has triggered.
void stop_action()
Stop any action connected to this trigger.
const optional< bool > & get_toggle() const
const optional< float > & get_position() const
optional< CoverRestoreState > restore_state_()
void publish_state(bool save=true)
Publish the current state of the cover.
float tilt
The current tilt value of the cover from 0.0 to 1.0.
float position
The position of the cover from 0.0 (fully closed) to 1.0 (fully open).
void set_has_toggle(bool has_toggle)
Trigger< float > * get_position_trigger() const
void set_has_stop(bool has_stop)
Trigger< float > * tilt_trigger_
Trigger< float > * get_tilt_trigger() const
TemplateLambda< float > state_f_
Trigger * get_close_trigger() const
Trigger * get_stop_trigger() const
void set_has_tilt(bool has_tilt)
void control(const cover::CoverCall &call) override
void set_has_position(bool has_position)
void set_assumed_state(bool assumed_state)
Trigger * prev_command_trigger_
void stop_prev_trigger_()
void dump_config() override
Trigger * toggle_trigger_
void set_optimistic(bool optimistic)
float get_setup_priority() const override
cover::CoverTraits get_traits() override
Trigger< float > * position_trigger_
Trigger * get_open_trigger() const
TemplateCoverRestoreMode restore_mode_
Trigger * get_toggle_trigger() const
TemplateLambda< float > tilt_f_
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.