52 const auto &traits = parent->traits;
59 float target_value = NAN;
60 float min_value = traits.get_min_value();
61 float max_value = traits.get_max_value();
64 ESP_LOGV(TAG,
"'%s': Setting value", name);
65 if (!this->
value_.has_value() || std::isnan(*this->value_)) {
69 target_value = this->
value_.value();
71 if (std::isnan(min_value)) {
74 target_value = min_value;
77 if (std::isnan(max_value)) {
80 target_value = max_value;
83 ESP_LOGV(TAG,
"'%s': Increment with%s cycling", name, this->
cycle_ ? LOG_STR_LITERAL(
"") : LOG_STR_LITERAL(
"out"));
84 if (!parent->has_state()) {
88 auto step = traits.get_step();
89 target_value = parent->state + (std::isnan(step) ? 1 : step);
90 if (target_value > max_value)
93 ESP_LOGV(TAG,
"'%s': Decrement with%s cycling", name, this->
cycle_ ? LOG_STR_LITERAL(
"") : LOG_STR_LITERAL(
"out"));
94 if (!parent->has_state()) {
98 auto step = traits.get_step();
99 target_value = parent->state - (std::isnan(step) ? 1 : step);
100 if (target_value < min_value)
104 if (target_value < min_value) {
108 if (target_value > max_value) {
113 ESP_LOGV(TAG,
" New value: %f", target_value);