Skip to content

Commit

Permalink
add unit of measurement in HA for analog sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
pswid committed Jun 21, 2022
1 parent 1c48d12 commit 1238e89
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/analogsensor.cpp
Expand Up @@ -411,6 +411,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");
Expand Down

0 comments on commit 1238e89

Please sign in to comment.