let sensors announce its state_class via mqtt (#2155)

This commit is contained in:
puuu 2021-08-16 04:59:29 +09:00 committed by GitHub
parent 9173da0416
commit 303b699005
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -61,6 +61,9 @@ void MQTTSensorComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryCo
if (this->sensor_->get_force_update())
root["force_update"] = true;
if (this->sensor_->state_class == sensor::STATE_CLASS_MEASUREMENT)
root["state_class"] = "measurement";
config.command_topic = false;
}
bool MQTTSensorComponent::send_initial_state() {