mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
add unit of measurement in HA for analog sensors
This commit is contained in:
@@ -412,6 +412,10 @@ void AnalogSensor::publish_values(const bool force) {
|
||||
snprintf(str, sizeof(str), "analogsensor_%d", sensor.gpio());
|
||||
config["uniq_id"] = str;
|
||||
|
||||
if (sensor.uom() != DeviceValueUOM::NONE) {
|
||||
config["unit_of_meas"] = EMSdevice::uom_to_string(sensor.uom());
|
||||
}
|
||||
|
||||
JsonObject dev = config.createNestedObject("dev");
|
||||
JsonArray ids = dev.createNestedArray("ids");
|
||||
ids.add("ems-esp");
|
||||
|
||||
Reference in New Issue
Block a user