mirror of
https://github.com/esphome/esphome.git
synced 2025-09-28 16:12:24 +01:00
Introduce parse_number() helper function (#2659)
This commit is contained in:
@@ -13,7 +13,7 @@ void MQTTSubscribeSensor::setup() {
|
||||
mqtt::global_mqtt_client->subscribe(
|
||||
this->topic_,
|
||||
[this](const std::string &topic, const std::string &payload) {
|
||||
auto val = parse_float(payload);
|
||||
auto val = parse_number<float>(payload);
|
||||
if (!val.has_value()) {
|
||||
ESP_LOGW(TAG, "Can't convert '%s' to number!", payload.c_str());
|
||||
this->publish_state(NAN);
|
||||
|
Reference in New Issue
Block a user