42 const auto &traits = parent->traits;
45 ESP_LOGW(TAG,
"'%s' - NumberCall performed without selecting an operation", name);
49 float target_value = NAN;
50 float min_value = traits.get_min_value();
51 float max_value = traits.get_max_value();
54 ESP_LOGD(TAG,
"'%s' - Setting number value", name);
56 ESP_LOGW(TAG,
"'%s' - No value set for NumberCall", name);
61 if (std::isnan(min_value)) {
62 ESP_LOGW(TAG,
"'%s' - Can't set to min value through NumberCall: no min_value defined", name);
64 target_value = min_value;
67 if (std::isnan(max_value)) {
68 ESP_LOGW(TAG,
"'%s' - Can't set to max value through NumberCall: no max_value defined", name);
70 target_value = max_value;
73 ESP_LOGD(TAG,
"'%s' - Increment number, with%s cycling", name, this->
cycle_ ?
"" :
"out");
74 if (!parent->has_state()) {
75 ESP_LOGW(TAG,
"'%s' - Can't increment number through NumberCall: no active state to modify", name);
78 auto step = traits.get_step();
79 target_value = parent->state + (std::isnan(step) ? 1 : step);
80 if (target_value > max_value) {
81 if (this->
cycle_ && !std::isnan(min_value)) {
82 target_value = min_value;
84 target_value = max_value;
88 ESP_LOGD(TAG,
"'%s' - Decrement number, with%s cycling", name, this->
cycle_ ?
"" :
"out");
89 if (!parent->has_state()) {
90 ESP_LOGW(TAG,
"'%s' - Can't decrement number through NumberCall: no active state to modify", name);
93 auto step = traits.get_step();
94 target_value = parent->state - (std::isnan(step) ? 1 : step);
95 if (target_value < min_value) {
96 if (this->
cycle_ && !std::isnan(max_value)) {
97 target_value = max_value;
99 target_value = min_value;
104 if (target_value < min_value) {
105 ESP_LOGW(TAG,
"'%s' - Value %f must not be less than minimum %f", name, target_value, min_value);
108 if (target_value > max_value) {
109 ESP_LOGW(TAG,
"'%s' - Value %f must not be greater than maximum %f", name, target_value, max_value);
113 ESP_LOGD(TAG,
" New number value: %f", target_value);