Fixes https://github.com/esphome/issues/issues/793 Also adds a clampd function that operates with doubles, not floats