13static const char *
const TAG =
"tuya.cover";
28 if (restore.has_value())
34 if (restore.has_value()) {
35 restore->to_call(
this).perform();
53 ESP_LOGD(TAG,
"Ignoring MCU position report - not calibrated");
63 if (
call.get_stop()) {
70 position_int = position_int + this->
min_value_;
75 auto pos_opt =
call.get_position();
76 if (pos_opt.has_value()) {
78 if (this->
control_id_.has_value() && (
pos == COVER_OPEN ||
pos == COVER_CLOSED)) {
79 if (
pos == COVER_OPEN) {
87 position_int = position_int + this->
min_value_;
102 ESP_LOGD(TAG,
"Setting direction: inverted");
104 ESP_LOGD(TAG,
"Setting direction: normal");
111 ESP_LOGCONFIG(TAG,
"Tuya Cover:");
114 ESP_LOGCONFIG(TAG,
" Inverted");
116 ESP_LOGCONFIG(TAG,
" Configured as Inverted, but direction_datapoint isn't configured");
120 ESP_LOGCONFIG(TAG,
" Position Reporting Inverted");
123 ESP_LOGCONFIG(TAG,
" Control has datapoint ID %u", *this->
control_id_);
126 ESP_LOGCONFIG(TAG,
" Direction has datapoint ID %u", *this->
direction_id_);
129 ESP_LOGCONFIG(TAG,
" Position has datapoint ID %u", *this->
position_id_);
138 traits.set_supports_stop(
true);
139 traits.set_supports_position(
true);
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).
void dump_config() override
optional< uint8_t > control_id_
cover::CoverTraits get_traits() override
optional< uint8_t > position_report_id_
bool invert_position_report_
void set_direction_(bool inverted)
optional< uint8_t > direction_id_
optional< uint8_t > position_id_
void control(const cover::CoverCall &call) override
TuyaCoverRestoreMode restore_mode_
void add_on_initialized_callback(std::function< void()> callback)
void set_boolean_datapoint_value(uint8_t datapoint_id, bool value)
void force_set_integer_datapoint_value(uint8_t datapoint_id, uint32_t value)
void register_listener(uint8_t datapoint_id, const std::function< void(TuyaDatapoint)> &func)
void force_set_enum_datapoint_value(uint8_t datapoint_id, uint8_t value)
const uint8_t COMMAND_OPEN
const uint8_t COMMAND_CLOSE
const uint8_t COMMAND_STOP
Providing packet encoding functions for exchanging data with a remote host.