mirror of
https://github.com/esphome/esphome.git
synced 2025-10-30 14:43:51 +00:00
Use Clang 11 (#1846)
This commit is contained in:
@@ -7,18 +7,19 @@ namespace mqtt_subscribe {
|
||||
static const char *TAG = "mqtt_subscribe.sensor";
|
||||
|
||||
void MQTTSubscribeSensor::setup() {
|
||||
mqtt::global_mqtt_client->subscribe(this->topic_,
|
||||
[this](const std::string &topic, std::string payload) {
|
||||
auto val = parse_float(payload);
|
||||
if (!val.has_value()) {
|
||||
ESP_LOGW(TAG, "Can't convert '%s' to number!", payload.c_str());
|
||||
this->publish_state(NAN);
|
||||
return;
|
||||
}
|
||||
mqtt::global_mqtt_client->subscribe(
|
||||
this->topic_,
|
||||
[this](const std::string &topic, std::string payload) {
|
||||
auto val = parse_float(payload);
|
||||
if (!val.has_value()) {
|
||||
ESP_LOGW(TAG, "Can't convert '%s' to number!", payload.c_str());
|
||||
this->publish_state(NAN);
|
||||
return;
|
||||
}
|
||||
|
||||
this->publish_state(*val);
|
||||
},
|
||||
this->qos_);
|
||||
this->publish_state(*val);
|
||||
},
|
||||
this->qos_);
|
||||
}
|
||||
|
||||
float MQTTSubscribeSensor::get_setup_priority() const { return setup_priority::AFTER_CONNECTION; }
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace mqtt_subscribe {
|
||||
static const char *TAG = "mqtt_subscribe.text_sensor";
|
||||
|
||||
void MQTTSubscribeTextSensor::setup() {
|
||||
this->parent_->subscribe(this->topic_,
|
||||
[this](const std::string &topic, std::string payload) { this->publish_state(payload); },
|
||||
this->qos_);
|
||||
this->parent_->subscribe(
|
||||
this->topic_, [this](const std::string &topic, std::string payload) { this->publish_state(payload); },
|
||||
this->qos_);
|
||||
}
|
||||
float MQTTSubscribeTextSensor::get_setup_priority() const { return setup_priority::AFTER_CONNECTION; }
|
||||
void MQTTSubscribeTextSensor::set_qos(uint8_t qos) { this->qos_ = qos; }
|
||||
|
||||
Reference in New Issue
Block a user