mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 09:17:46 +01:00
let sensors announce its state_class via mqtt (#2155)
This commit is contained in:
parent
9efeea14f2
commit
bd457f64d8
1 changed files with 3 additions and 0 deletions
|
@ -61,6 +61,9 @@ void MQTTSensorComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryCo
|
||||||
if (this->sensor_->get_force_update())
|
if (this->sensor_->get_force_update())
|
||||||
root["force_update"] = true;
|
root["force_update"] = true;
|
||||||
|
|
||||||
|
if (this->sensor_->state_class == sensor::STATE_CLASS_MEASUREMENT)
|
||||||
|
root["state_class"] = "measurement";
|
||||||
|
|
||||||
config.command_topic = false;
|
config.command_topic = false;
|
||||||
}
|
}
|
||||||
bool MQTTSensorComponent::send_initial_state() {
|
bool MQTTSensorComponent::send_initial_state() {
|
||||||
|
|
Loading…
Reference in a new issue