mirror of
https://github.com/esphome/esphome.git
synced 2025-09-29 00:22:21 +01:00
Introduce parse_number() helper function (#2659)
This commit is contained in:
@@ -10,7 +10,7 @@ static const char *const TAG = "homeassistant.sensor";
|
||||
void HomeassistantSensor::setup() {
|
||||
api::global_api_server->subscribe_home_assistant_state(
|
||||
this->entity_id_, this->attribute_, [this](const std::string &state) {
|
||||
auto val = parse_float(state);
|
||||
auto val = parse_number<float>(state);
|
||||
if (!val.has_value()) {
|
||||
ESP_LOGW(TAG, "Can't convert '%s' to number!", state.c_str());
|
||||
this->publish_state(NAN);
|
||||
|
Reference in New Issue
Block a user