mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 23:18:10 +01:00
catch 0.0 in float set_level pre-adjustment (#2013)
This commit is contained in:
parent
07ae8ec553
commit
08b67e7aea
1 changed files with 4 additions and 0 deletions
|
@ -31,6 +31,10 @@ void FloatOutput::set_level(float state) {
|
||||||
#endif
|
#endif
|
||||||
if (this->is_inverted())
|
if (this->is_inverted())
|
||||||
state = 1.0f - state;
|
state = 1.0f - state;
|
||||||
|
if (state == 0.0f) { // regardless of min_power_, 0.0 means off
|
||||||
|
this->write_state(state);
|
||||||
|
return;
|
||||||
|
}
|
||||||
float adjusted_value = (state * (this->max_power_ - this->min_power_)) + this->min_power_;
|
float adjusted_value = (state * (this->max_power_ - this->min_power_)) + this->min_power_;
|
||||||
this->write_state(adjusted_value);
|
this->write_state(adjusted_value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue