7 static const char *
const TAG =
"tuya.number";
16 ESP_LOGV(TAG,
"MCU reported number %u is: %d", datapoint.id, datapoint.value_int);
17 float value = datapoint.value_int / multiply_by_;
18 this->publish_state(value);
19 if (this->restore_value_)
20 this->pref_.save(&value);
22 ESP_LOGV(TAG,
"MCU reported number %u is: %u", datapoint.id, datapoint.value_enum);
23 float value = datapoint.value_enum;
24 this->publish_state(value);
25 if (this->restore_value_)
26 this->pref_.save(&value);
28 ESP_LOGW(TAG,
"Reported type (%d) is not a number!", static_cast<int>(datapoint.type));
33 ESP_LOGW(TAG,
"Reported type (%d) different than previously set (%d)!", static_cast<int>(datapoint.type),
34 static_cast<int>(*this->type_));
36 this->type_ = datapoint.
type;
54 ESP_LOGW(TAG,
"Failed to restore and there is no initial value defined. Setting min_value (%f)", value);
65 ESP_LOGV(TAG,
"Setting number %u: %f", this->
number_id_, value);
79 LOG_NUMBER(
"",
"Tuya Number",
this);
80 ESP_LOGCONFIG(TAG,
" Number has datapoint ID %u", this->
number_id_);
82 ESP_LOGCONFIG(TAG,
" Datapoint type is %d", static_cast<int>(*this->
type_));
84 ESP_LOGCONFIG(TAG,
" Datapoint type is unknown");
91 ESP_LOGCONFIG(TAG,
" Restore Value: %s", YESNO(this->
restore_value_));
void set_enum_datapoint_value(uint8_t datapoint_id, uint8_t value)
ESPPreferenceObject pref_
void publish_state(float state)
void register_listener(uint8_t datapoint_id, const std::function< void(TuyaDatapoint)> &func)
void add_on_initialized_callback(std::function< void()> callback)
void control(float value) override
ESPPreferences * global_preferences
void dump_config() override
void set_integer_datapoint_value(uint8_t datapoint_id, uint32_t value)
virtual ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)=0
optional< float > initial_value_
Implementation of SPI Controller mode.
float get_min_value() const
optional< TuyaDatapointType > type_
uint32_t get_object_id_hash()