1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 19:32:19 +01:00

catch 0.0 in float set_level pre-adjustment (#2013)

This commit is contained in:
WeekendWarrior1
2021-07-14 12:43:30 +10:00
committed by GitHub
parent 07ae8ec553
commit 08b67e7aea

View File

@@ -31,6 +31,10 @@ void FloatOutput::set_level(float state) {
#endif
if (this->is_inverted())
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_;
this->write_state(adjusted_value);
}