9static const char *
const TAG =
"he60r.cover";
10static const uint8_t QUERY_BYTE = 0x38;
11static const uint8_t TOGGLE_BYTE = 0x30;
18 if (restore.has_value()) {
32 traits.set_supports_stop(
true);
33 traits.set_supports_position(
true);
34 traits.set_supports_toggle(
true);
35 traits.set_is_assumed_state(
false);
40 LOG_COVER(
"",
"HE60R Cover",
this);
43 " Open Duration: %.1fs\n"
44 " Close Duration: %.1fs",
47 if (restore.has_value())
48 ESP_LOGCONFIG(TAG,
" Saved position %d%%", (
int) (restore->position * 100.f));
61 ESP_LOGD(TAG,
"'%s' - %s endstop reached. Took %.1fs.", this->
name_.
c_str(),
77 ESP_LOGV(TAG,
"Process RX data %X", data);
81 ESP_LOGD(TAG,
"RX Byte %02X", data);
130 if ((this->
counter_++ & 0x3) == 0) {
132 ESP_LOGD(TAG,
"Writing byte 0x30, still needed=%u", this->
toggles_needed_);
164 if (
call.get_stop()) {
174 auto pos_opt =
call.get_position();
175 if (!pos_opt.has_value())
215 ESP_LOGD(TAG,
"'%s' - Direction '%s' requested.", this->
name_.
c_str(),
231 ESP_LOGD(TAG,
"'%s' - Reversing direction.", this->
name_.
c_str());
256 auto new_position = clamp(delta + this->
position, COVER_CLOSED + 0.01f, COVER_OPEN - 0.01f);
257 ESP_LOGD(TAG,
"Recompute %ums, dir=%u, delta=%f, pos=%f", diff, this->
current_operation, delta, new_position);
259 if (this->
position != new_position) {
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") void set_interval(const std voi set_interval)(const char *name, uint32_t interval, std::function< void()> &&f)
Set an interval function with a unique name.
constexpr const char * c_str() const
const optional< bool > & get_toggle() const
CoverOperation current_operation
The current operation of the cover (idle, opening, closing).
optional< CoverRestoreState > restore_state_()
void publish_state(bool save=true)
Publish the current state of the cover.
float position
The position of the cover from 0.0 (fully closed) to 1.0 (fully open).
bool is_at_target_() const
Check if the cover has reached or passed the target position.
void control(const cover::CoverCall &call) override
cover::CoverOperation last_command_
cover::CoverTraits get_traits() override
void recompute_position_()
void endstop_reached_(cover::CoverOperation operation)
uint32_t last_recompute_time_
void set_current_operation_(cover::CoverOperation operation)
void process_rx_(uint8_t data)
cover::CoverOperation next_direction_
void dump_config() override
void start_direction_(cover::CoverOperation dir)
void check_uart_settings(uint32_t baud_rate, uint8_t stop_bits=1, UARTParityOptions parity=UART_CONFIG_PARITY_NONE, uint8_t data_bits=8)
Check that the configuration of the UART bus matches the provided values and otherwise print a warnin...
bool read_byte(uint8_t *data)
void write_byte(uint8_t data)
CoverOperation
Enum encoding the current operation of a cover.
@ COVER_OPERATION_OPENING
The cover is currently opening.
@ COVER_OPERATION_CLOSING
The cover is currently closing.
@ COVER_OPERATION_IDLE
The cover is currently idle (not moving)
@ UART_CONFIG_PARITY_EVEN
uint32_t IRAM_ATTR HOT millis()