mirror of
https://github.com/esphome/esphome.git
synced 2025-10-06 20:03:46 +01:00
Introduce parse_number() helper function (#2659)
This commit is contained in:
@@ -71,7 +71,7 @@ void MQTTFanComponent::setup() {
|
||||
if (this->state_->get_traits().supports_speed()) {
|
||||
this->subscribe(this->get_speed_level_command_topic(),
|
||||
[this](const std::string &topic, const std::string &payload) {
|
||||
optional<int> speed_level_opt = parse_int(payload);
|
||||
optional<int> speed_level_opt = parse_number<int>(payload);
|
||||
if (speed_level_opt.has_value()) {
|
||||
const int speed_level = speed_level_opt.value();
|
||||
if (speed_level >= 0 && speed_level <= this->state_->get_traits().supported_speed_count()) {
|
||||
|
Reference in New Issue
Block a user