diff --git a/CHANGELOG.md b/CHANGELOG.md index 5976db3..c24076f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,20 @@ # CHANGELOG +## v0.2.4 +### Added +- Convert the submersion-state, the contact-state and the occupancy-status property to the binary_sensor entity. [#905](https://github.com/XiaoMi/ha_xiaomi_home/pull/905) + +### Changed +- suittc.airrtc.wk168 mode descriptions are set to strings of numbers from 1 to 16. [#921](https://github.com/XiaoMi/ha_xiaomi_home/pull/921) +- Do not set _attr_suggested_display_precision when the spec.expr is set in spec_modify.yaml [#929](https://github.com/XiaoMi/ha_xiaomi_home/pull/929) +- Set "unknown event msg" log to info level. +### Fixed +- hhcc.plantmonitor.v1 soil moisture and soil ec icon and unit. [#927](https://github.com/XiaoMi/ha_xiaomi_home/pull/27) +- cuco.plug.cp2 voltage and power value ratio. +- cgllc.airmonitor.s1 unit ppb. +- roswan.waterpuri.lte01 tds unit. +- lumi.relay.c2acn01 power consumption unit +- xiaomi.bhf_light.s1 fan level of ventilation. + ## v0.2.3 ### Changed - Specify the service name and the property name during the climate entity's on/off feature initialization. [#899](https://github.com/XiaoMi/ha_xiaomi_home/pull/899) diff --git a/custom_components/xiaomi_home/binary_sensor.py b/custom_components/xiaomi_home/binary_sensor.py index aca45d8..8019104 100644 --- a/custom_components/xiaomi_home/binary_sensor.py +++ b/custom_components/xiaomi_home/binary_sensor.py @@ -89,4 +89,8 @@ class BinarySensor(MIoTPropertyEntity, BinarySensorEntity): @property def is_on(self) -> bool: """On/Off state. True if the binary sensor is on, False otherwise.""" + if self.spec.name == 'contact-state': + return self._value is False + elif self.spec.name == 'occupancy-status': + return bool(self._value) return self._value is True diff --git a/custom_components/xiaomi_home/manifest.json b/custom_components/xiaomi_home/manifest.json index 1059f89..636b2bd 100644 --- a/custom_components/xiaomi_home/manifest.json +++ b/custom_components/xiaomi_home/manifest.json @@ -25,7 +25,7 @@ "cryptography", "psutil" ], - "version": "v0.2.3", + "version": "v0.2.4", "zeroconf": [ "_miot-central._tcp.local." ] diff --git a/custom_components/xiaomi_home/miot/miot_mips.py b/custom_components/xiaomi_home/miot/miot_mips.py index d59d439..f1a4534 100644 --- a/custom_components/xiaomi_home/miot/miot_mips.py +++ b/custom_components/xiaomi_home/miot/miot_mips.py @@ -1215,7 +1215,7 @@ class MipsLocalClient(_MipsClient): or 'eiid' not in msg # or 'arguments' not in msg ): - self.log_error('unknown event msg, %s', payload) + self.log_info('unknown event msg, %s', payload) return if 'arguments' not in msg: self.log_info('wrong event msg, %s', payload) diff --git a/custom_components/xiaomi_home/miot/specs/spec_modify.yaml b/custom_components/xiaomi_home/miot/specs/spec_modify.yaml index f08d890..604e977 100644 --- a/custom_components/xiaomi_home/miot/specs/spec_modify.yaml +++ b/custom_components/xiaomi_home/miot/specs/spec_modify.yaml @@ -121,11 +121,33 @@ 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 +urn:miot-spec-v2:device:relay:0000A03D:lumi-c2acn01:1: + prop.4.1: + unit: kWh +urn:miot-spec-v2:device:bath-heater:0000A028:xiaomi-s1:1: + prop.4.4: + name: fan-level-ventilation diff --git a/custom_components/xiaomi_home/miot/specs/specv2entity.py b/custom_components/xiaomi_home/miot/specs/specv2entity.py index 7adbcc6..8c46939 100644 --- a/custom_components/xiaomi_home/miot/specs/specv2entity.py +++ b/custom_components/xiaomi_home/miot/specs/specv2entity.py @@ -48,6 +48,7 @@ Conversion rules of MIoT-Spec-V2 instance to Home Assistant entity. from homeassistant.components.sensor import SensorDeviceClass from homeassistant.components.sensor import SensorStateClass from homeassistant.components.event import EventDeviceClass +from homeassistant.components.binary_sensor import BinarySensorDeviceClass from homeassistant.const import ( CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, @@ -454,12 +455,28 @@ SPEC_PROP_TRANS_MAP: dict = { 'format': {'int', 'float'}, 'access': {'read'} }, + 'binary_sensor': { + 'format': {'bool', 'int'}, + 'access': {'read'} + }, 'switch': { 'format': {'bool'}, 'access': {'read', 'write'} } }, 'properties': { + 'submersion-state': { + 'device_class': BinarySensorDeviceClass.MOISTURE, + 'entity': 'binary_sensor' + }, + 'contact-state': { + 'device_class': BinarySensorDeviceClass.DOOR, + 'entity': 'binary_sensor' + }, + 'occupancy-status': { + 'device_class': BinarySensorDeviceClass.OCCUPANCY, + 'entity': 'binary_sensor', + }, 'temperature': { 'device_class': SensorDeviceClass.TEMPERATURE, 'entity': 'sensor', @@ -506,7 +523,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: