1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-16 14:55:50 +00:00

Fix mqtt_text_sensor to honor unique_id when set. (#698)

* Fix mqtt_text_sensor to honor unique_id when set.
* Remove setting of unique_id in json tree, as the mqtt_component already does this, and in fact overrides what we do here.
* Add unqiue_id() and dump_config() to the wifi_info sensors.
This commit is contained in:
Pauline Middelink
2019-08-27 19:28:50 +02:00
committed by Brandon Davidson
parent 655327a8b1
commit 071272a27f
3 changed files with 11 additions and 3 deletions

View File

@@ -15,9 +15,6 @@ void MQTTTextSensor::send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig
if (!this->sensor_->get_icon().empty())
root["icon"] = this->sensor_->get_icon();
if (!this->sensor_->unique_id().empty())
root["unique_id"] = this->sensor_->unique_id();
config.command_topic = false;
}
void MQTTTextSensor::setup() {
@@ -40,6 +37,7 @@ bool MQTTTextSensor::send_initial_state() {
bool MQTTTextSensor::is_internal() { return this->sensor_->is_internal(); }
std::string MQTTTextSensor::component_type() const { return "sensor"; }
std::string MQTTTextSensor::friendly_name() const { return this->sensor_->get_name(); }
std::string MQTTTextSensor::unique_id() { return this->sensor_->unique_id(); }
} // namespace mqtt
} // namespace esphome