diff --git a/custom_components/xiaomi_home/miot/specs/spec_modify.yaml b/custom_components/xiaomi_home/miot/specs/spec_modify.yaml index f08d890..d144ea7 100644 --- a/custom_components/xiaomi_home/miot/specs/spec_modify.yaml +++ b/custom_components/xiaomi_home/miot/specs/spec_modify.yaml @@ -121,11 +121,27 @@ urn:miot-spec-v2:device:outlet:0000A002:chuangmi-212a01:3: expr: round(src_value*6/1000000, 3) urn:miot-spec-v2:device:outlet:0000A002:chuangmi-212a01:1: urn:miot-spec-v2:device:outlet:0000A002:chuangmi-212a01:3 urn:miot-spec-v2:device:outlet:0000A002:chuangmi-212a01:2: urn:miot-spec-v2:device:outlet:0000A002:chuangmi-212a01:3 +urn:miot-spec-v2:device:outlet:0000A002:cuco-cp2:2: + prop.2.3: + expr: round(src_value/10, 1) + prop.2.4: + unit: mA + prop.3.2: + expr: round(src_value/10, 1) +urn:miot-spec-v2:device:outlet:0000A002:cuco-cp2:1: urn:miot-spec-v2:device:outlet:0000A002:cuco-cp2:2 urn:miot-spec-v2:device:plant-monitor:0000A030:hhcc-v1:1: - prop.2.1: - name: soil-moisture - icon: mdi:watering-can - prop.2.2: - name: soil-ec - icon: mdi:sprout-outline - unit: μS/cm + prop.2.1: + name: soil-moisture + icon: mdi:watering-can + prop.2.2: + name: soil-ec + icon: mdi:sprout-outline + unit: μS/cm +urn:miot-spec-v2:device:air-monitor:0000A008:cgllc-s1:1: + prop.2.5: + name: voc-density +urn:miot-spec-v2:device:water-purifier:0000A013:roswan-lte01:1:0000D05A: + prop.4.1: + unit: ppm + prop.4.2: + unit: ppm diff --git a/custom_components/xiaomi_home/miot/specs/specv2entity.py b/custom_components/xiaomi_home/miot/specs/specv2entity.py index 7adbcc6..511dd07 100644 --- a/custom_components/xiaomi_home/miot/specs/specv2entity.py +++ b/custom_components/xiaomi_home/miot/specs/specv2entity.py @@ -506,7 +506,11 @@ SPEC_PROP_TRANS_MAP: dict = { 'entity': 'sensor', 'state_class': SensorStateClass.MEASUREMENT }, - 'voc-density': 'tvoc-density', + 'voc-density': { + 'device_class': SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS, + 'entity': 'sensor', + 'state_class': SensorStateClass.MEASUREMENT + }, 'battery-level': { 'device_class': SensorDeviceClass.BATTERY, 'entity': 'sensor', diff --git a/custom_components/xiaomi_home/sensor.py b/custom_components/xiaomi_home/sensor.py index fb9f30b..88cb063 100644 --- a/custom_components/xiaomi_home/sensor.py +++ b/custom_components/xiaomi_home/sensor.py @@ -110,7 +110,7 @@ class Sensor(MIoTPropertyEntity, SensorEntity): self._attr_native_unit_of_measurement = list( unit_sets)[0] if unit_sets else None # Set suggested precision - if spec.format_ in {int, float}: + if spec.format_ in {int, float} and spec.expr is None: self._attr_suggested_display_precision = spec.precision # Set state_class if spec.state_class: