mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-31 02:41:54 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60d054cf19 | ||
|
|
6680d9e8cb | ||
|
|
0ef8cb6370 | ||
|
|
8f0a69c611 | ||
|
|
8be0fa5d61 | ||
|
|
07cb4ed193 |
16
CHANGELOG.md
16
CHANGELOG.md
@@ -1,13 +1,25 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## v0.2.2
|
||||||
|
This version has modified the conversion rules of the climate entity, which will have effect on the devices with the ptc-bath-heater, the air-conditioner and the air-fresh service. After updating, you need to restart Home Assistant and check `xiaomi_home > CONFIGURE >
|
||||||
|
Update entity conversion rules > NEXT` to reload the integration.
|
||||||
|
|
||||||
|
这个版本修改了浴霸、空调、新风机的实体转换规则,更新之后需要重启 Home Assistant,并且勾选 `xiaomi_home > 配置 > 更新实体转换规则 > 下一步` 重新加载集成。
|
||||||
|
### Added
|
||||||
|
- Add conversion rules for the air-conditioner service and the air-fresh service. [#879](https://github.com/XiaoMi/ha_xiaomi_home/pull/879)
|
||||||
|
### Changed
|
||||||
|
- Convert the mode of the ptc bath heater to the preset mode of the climate entity. [#874](https://github.com/XiaoMi/ha_xiaomi_home/pull/874)
|
||||||
|
- Use Home Assistant default icon when device_class is set. [#855](https://github.com/XiaoMi/ha_xiaomi_home/pull/855)
|
||||||
|
### Fixed
|
||||||
|
- Fix xiaomi.aircondition.m9 humidity-range unit. [#878](https://github.com/XiaoMi/ha_xiaomi_home/pull/878)
|
||||||
|
- Fix MIoT-Spec-V2 conflicts of xiaomi.fan.p5 and mike.bhf_light.2. [#866](https://github.com/XiaoMi/ha_xiaomi_home/pull/866)
|
||||||
|
|
||||||
## v0.2.1
|
## v0.2.1
|
||||||
### Added
|
### Added
|
||||||
- Add the preset mode for the thermostat. [#833](https://github.com/XiaoMi/ha_xiaomi_home/pull/833)
|
- Add the preset mode for the thermostat. [#833](https://github.com/XiaoMi/ha_xiaomi_home/pull/833)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Change paho-mqtt version to adapt Home Assistant 2025.03. [#839](https://github.com/XiaoMi/ha_xiaomi_home/pull/839)
|
- Change paho-mqtt version to adapt Home Assistant 2025.03. [#839](https://github.com/XiaoMi/ha_xiaomi_home/pull/839)
|
||||||
- Revert to use multi_lang.json. [#834](https://github.com/XiaoMi/ha_xiaomi_home/pull/834)
|
- Revert to use multi_lang.json. [#834](https://github.com/XiaoMi/ha_xiaomi_home/pull/834)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix the opening and the closing status of linp.wopener.wd1lb. [#826](https://github.com/XiaoMi/ha_xiaomi_home/pull/826)
|
- Fix the opening and the closing status of linp.wopener.wd1lb. [#826](https://github.com/XiaoMi/ha_xiaomi_home/pull/826)
|
||||||
- Fix the format type of the wind-reverse property. [#810](https://github.com/XiaoMi/ha_xiaomi_home/pull/810)
|
- Fix the format type of the wind-reverse property. [#810](https://github.com/XiaoMi/ha_xiaomi_home/pull/810)
|
||||||
|
|||||||
@@ -605,7 +605,7 @@ class AirConditioner(FeatureOnOff, FeatureTargetTemperature,
|
|||||||
|
|
||||||
|
|
||||||
class PtcBathHeater(FeatureTargetTemperature, FeatureTemperature,
|
class PtcBathHeater(FeatureTargetTemperature, FeatureTemperature,
|
||||||
FeatureFanMode, FeatureSwingMode):
|
FeatureFanMode, FeatureSwingMode, FeaturePresetMode):
|
||||||
"""Ptc bath heater"""
|
"""Ptc bath heater"""
|
||||||
_prop_mode: Optional[MIoTSpecProperty]
|
_prop_mode: Optional[MIoTSpecProperty]
|
||||||
_hvac_mode_map: Optional[dict[int, HVACMode]]
|
_hvac_mode_map: Optional[dict[int, HVACMode]]
|
||||||
@@ -626,26 +626,20 @@ class PtcBathHeater(FeatureTargetTemperature, FeatureTemperature,
|
|||||||
continue
|
continue
|
||||||
self._hvac_mode_map = {}
|
self._hvac_mode_map = {}
|
||||||
for item in prop.value_list.items:
|
for item in prop.value_list.items:
|
||||||
if item.name in {'off', 'idle'
|
if item.name in {'off', 'idle'}:
|
||||||
} and (HVACMode.OFF not in list(
|
if (HVACMode.OFF
|
||||||
self._hvac_mode_map.values())):
|
not in list(self._hvac_mode_map.values())):
|
||||||
self._hvac_mode_map[item.value] = HVACMode.OFF
|
self._hvac_mode_map[item.value] = HVACMode.OFF
|
||||||
elif item.name in {'auto'}:
|
elif (HVACMode.AUTO
|
||||||
|
not in list(self._hvac_mode_map.values())):
|
||||||
self._hvac_mode_map[item.value] = HVACMode.AUTO
|
self._hvac_mode_map[item.value] = HVACMode.AUTO
|
||||||
elif item.name in {'ventilate'}:
|
|
||||||
self._hvac_mode_map[item.value] = HVACMode.COOL
|
|
||||||
elif item.name in {'heat', 'quick_heat'
|
|
||||||
} and (HVACMode.HEAT not in list(
|
|
||||||
self._hvac_mode_map.values())):
|
|
||||||
self._hvac_mode_map[item.value] = HVACMode.HEAT
|
|
||||||
elif item.name in {'defog'}:
|
|
||||||
self._hvac_mode_map[item.value] = HVACMode.HEAT_COOL
|
|
||||||
elif item.name in {'dry'}:
|
|
||||||
self._hvac_mode_map[item.value] = HVACMode.DRY
|
|
||||||
elif item.name in {'fan'}:
|
|
||||||
self._hvac_mode_map[item.value] = HVACMode.FAN_ONLY
|
|
||||||
self._attr_hvac_modes = list(self._hvac_mode_map.values())
|
self._attr_hvac_modes = list(self._hvac_mode_map.values())
|
||||||
self._prop_mode = prop
|
if HVACMode.OFF in self._attr_hvac_modes:
|
||||||
|
self._prop_mode = prop
|
||||||
|
else:
|
||||||
|
_LOGGER.error('no idle mode, %s', self.entity_id)
|
||||||
|
# preset modes
|
||||||
|
self._init_preset_modes('ptc-bath-heater', 'mode')
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||||
"""Set the target hvac mode."""
|
"""Set the target hvac mode."""
|
||||||
@@ -655,15 +649,20 @@ class PtcBathHeater(FeatureTargetTemperature, FeatureTemperature,
|
|||||||
if mode_value is None or not await self.set_property_async(
|
if mode_value is None or not await self.set_property_async(
|
||||||
prop=self._prop_mode, value=mode_value):
|
prop=self._prop_mode, value=mode_value):
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
f'set climate prop.mode failed, {hvac_mode}, {self.entity_id}')
|
f'set ptc-bath-heater {hvac_mode} failed, {self.entity_id}')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_mode(self) -> Optional[HVACMode]:
|
def hvac_mode(self) -> Optional[HVACMode]:
|
||||||
"""The current hvac mode."""
|
"""The current hvac mode."""
|
||||||
return (self.get_map_value(map_=self._hvac_mode_map,
|
if self._prop_mode is None:
|
||||||
key=self.get_prop_value(
|
return None
|
||||||
prop=self._prop_mode))
|
mode_value = self.get_map_value(
|
||||||
if self._prop_mode else None)
|
map_=self._hvac_mode_map,
|
||||||
|
key=self.get_prop_value(prop=self._prop_mode))
|
||||||
|
if mode_value == HVACMode.OFF or mode_value is None:
|
||||||
|
return mode_value
|
||||||
|
return HVACMode.AUTO if (HVACMode.AUTO
|
||||||
|
in self._attr_hvac_modes) else None
|
||||||
|
|
||||||
|
|
||||||
class Thermostat(FeatureOnOff, FeatureTargetTemperature, FeatureTemperature,
|
class Thermostat(FeatureOnOff, FeatureTargetTemperature, FeatureTemperature,
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ off Xiaomi or its affiliates' products.
|
|||||||
Event entities for Xiaomi Home.
|
Event entities for Xiaomi Home.
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@@ -57,6 +58,8 @@ from .miot.miot_spec import MIoTSpecEvent
|
|||||||
from .miot.miot_device import MIoTDevice, MIoTEventEntity
|
from .miot.miot_device import MIoTDevice, MIoTEventEntity
|
||||||
from .miot.const import DOMAIN
|
from .miot.const import DOMAIN
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@@ -89,4 +92,5 @@ class Event(MIoTEventEntity, EventEntity):
|
|||||||
self, name: str, arguments: dict[str, Any] | None = None
|
self, name: str, arguments: dict[str, Any] | None = None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""An event is occurred."""
|
"""An event is occurred."""
|
||||||
|
_LOGGER.debug('%s, attributes: %s', name, str(arguments))
|
||||||
self._trigger_event(event_type=name, event_attributes=arguments)
|
self._trigger_event(event_type=name, event_attributes=arguments)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
"cryptography",
|
"cryptography",
|
||||||
"psutil"
|
"psutil"
|
||||||
],
|
],
|
||||||
"version": "v0.2.1",
|
"version": "v0.2.2",
|
||||||
"zeroconf": [
|
"zeroconf": [
|
||||||
"_miot-central._tcp.local."
|
"_miot-central._tcp.local."
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -591,13 +591,8 @@ class MIoTDevice:
|
|||||||
# Priority: spec_modify.unit > unit_convert > specv2entity.unit
|
# Priority: spec_modify.unit > unit_convert > specv2entity.unit
|
||||||
miot_prop.external_unit = SPEC_PROP_TRANS_MAP['properties'][
|
miot_prop.external_unit = SPEC_PROP_TRANS_MAP['properties'][
|
||||||
prop_name]['unit_of_measurement']
|
prop_name]['unit_of_measurement']
|
||||||
if (
|
# Priority: default.icon when device_class is set > spec_modify.icon
|
||||||
not miot_prop.icon
|
# > icon_convert
|
||||||
and 'icon' in SPEC_PROP_TRANS_MAP['properties'][prop_name]
|
|
||||||
):
|
|
||||||
# Priority: spec_modify.icon > icon_convert > specv2entity.icon
|
|
||||||
miot_prop.icon = SPEC_PROP_TRANS_MAP['properties'][prop_name][
|
|
||||||
'icon']
|
|
||||||
miot_prop.platform = platform
|
miot_prop.platform = platform
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -1215,9 +1215,10 @@ class MipsLocalClient(_MipsClient):
|
|||||||
or 'eiid' not in msg
|
or 'eiid' not in msg
|
||||||
# or 'arguments' not in msg
|
# or 'arguments' not in msg
|
||||||
):
|
):
|
||||||
# self.log_error(f'on_event_msg, recv unknown msg, {payload}')
|
self.log_error('unknown event msg, %s', payload)
|
||||||
return
|
return
|
||||||
if 'arguments' not in msg:
|
if 'arguments' not in msg:
|
||||||
|
self.log_info('wrong event msg, %s', payload)
|
||||||
msg['arguments'] = []
|
msg['arguments'] = []
|
||||||
if handler:
|
if handler:
|
||||||
self.log_debug('local, on event_occurred, %s', payload)
|
self.log_debug('local, on event_occurred, %s', payload)
|
||||||
|
|||||||
@@ -1205,6 +1205,9 @@ class _SpecModify:
|
|||||||
if isinstance(self._selected, str):
|
if isinstance(self._selected, str):
|
||||||
return await self.set_spec_async(urn=self._selected)
|
return await self.set_spec_async(urn=self._selected)
|
||||||
|
|
||||||
|
def get_prop_name(self, siid: int, piid: int) -> Optional[str]:
|
||||||
|
return self.__get_prop_item(siid=siid, piid=piid, key='name')
|
||||||
|
|
||||||
def get_prop_unit(self, siid: int, piid: int) -> Optional[str]:
|
def get_prop_unit(self, siid: int, piid: int) -> Optional[str]:
|
||||||
return self.__get_prop_item(siid=siid, piid=piid, key='unit')
|
return self.__get_prop_item(siid=siid, piid=piid, key='unit')
|
||||||
|
|
||||||
@@ -1518,6 +1521,10 @@ class MIoTSpecParser:
|
|||||||
siid=service['iid'], piid=property_['iid'])
|
siid=service['iid'], piid=property_['iid'])
|
||||||
if custom_range:
|
if custom_range:
|
||||||
spec_prop.value_range = custom_range
|
spec_prop.value_range = custom_range
|
||||||
|
custom_name = self._spec_modify.get_prop_name(
|
||||||
|
siid=service['iid'], piid=property_['iid'])
|
||||||
|
if custom_name:
|
||||||
|
spec_prop.name = custom_name
|
||||||
# Parse service event
|
# Parse service event
|
||||||
for event in service.get('events', []):
|
for event in service.get('events', []):
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -58,3 +58,21 @@ urn:miot-spec-v2:device:bath-heater:0000A028:opple-acmoto:1:
|
|||||||
description: medium
|
description: medium
|
||||||
- value: 255
|
- value: 255
|
||||||
description: high
|
description: high
|
||||||
|
urn:miot-spec-v2:device:bath-heater:0000A028:mike-2:1:
|
||||||
|
prop.3.1:
|
||||||
|
name: mode-a
|
||||||
|
prop.3.11:
|
||||||
|
name: mode-b
|
||||||
|
prop.3.12:
|
||||||
|
name: mode-c
|
||||||
|
urn:miot-spec-v2:device:fan:0000A005:xiaomi-p51:1:
|
||||||
|
prop.2.2:
|
||||||
|
name: fan-level-a
|
||||||
|
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:6:
|
||||||
|
prop.10.6:
|
||||||
|
unit: none
|
||||||
|
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:1: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:6
|
||||||
|
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:2: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:6
|
||||||
|
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:3: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:6
|
||||||
|
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:4: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:6
|
||||||
|
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:5: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:6
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
|||||||
'optional': {
|
'optional': {
|
||||||
'properties': {'mode', 'target-humidity'}
|
'properties': {'mode', 'target-humidity'}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'optional': {
|
'optional': {
|
||||||
'environment': {
|
'environment': {
|
||||||
@@ -164,8 +164,7 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
|||||||
'continue-sweep',
|
'continue-sweep',
|
||||||
'stop-and-gocharge'
|
'stop-and-gocharge'
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'optional': {
|
'optional': {
|
||||||
@@ -178,9 +177,9 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
|||||||
'required': {
|
'required': {
|
||||||
'properties': {
|
'properties': {
|
||||||
'battery-level': {'read'}
|
'battery-level': {'read'}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'entity': 'vacuum'
|
'entity': 'vacuum'
|
||||||
},
|
},
|
||||||
@@ -196,7 +195,7 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
|||||||
},
|
},
|
||||||
'optional': {
|
'optional': {
|
||||||
'properties': {'target-humidity'}
|
'properties': {'target-humidity'}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'optional': {
|
'optional': {
|
||||||
@@ -237,7 +236,7 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
|||||||
'properties': {
|
'properties': {
|
||||||
'target-temperature', 'mode', 'fan-level',
|
'target-temperature', 'mode', 'fan-level',
|
||||||
'temperature'}
|
'temperature'}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'optional': {
|
'optional': {
|
||||||
@@ -246,7 +245,7 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
|||||||
'optional': {
|
'optional': {
|
||||||
'properties': {'temperature', 'relative-humidity'}
|
'properties': {'temperature', 'relative-humidity'}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'entity': 'thermostat'
|
'entity': 'thermostat'
|
||||||
},
|
},
|
||||||
@@ -260,7 +259,7 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
|||||||
},
|
},
|
||||||
'optional': {
|
'optional': {
|
||||||
'properties': {'target-temperature', 'heat-level'}
|
'properties': {'target-temperature', 'heat-level'}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'optional': {
|
'optional': {
|
||||||
@@ -269,20 +268,21 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
|||||||
'optional': {
|
'optional': {
|
||||||
'properties': {'temperature', 'relative-humidity'}
|
'properties': {'temperature', 'relative-humidity'}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'entity': 'heater'
|
'entity': 'heater'
|
||||||
},
|
},
|
||||||
'bath-heater': {
|
'bath-heater': {
|
||||||
'required': {
|
'required': {
|
||||||
'ptc-bath-heater': {
|
'ptc-bath-heater': {
|
||||||
'required': {},
|
'required': {
|
||||||
'optional': {
|
|
||||||
'properties': {
|
'properties': {
|
||||||
'target-temperature', 'heat-level',
|
'mode':{'read', 'write'}
|
||||||
'temperature', 'mode'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'optional': {
|
||||||
|
'properties': {'target-temperature', 'temperature'}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'optional': {
|
'optional': {
|
||||||
@@ -292,7 +292,13 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
|||||||
'properties': {
|
'properties': {
|
||||||
'on', 'fan-level', 'horizontal-swing', 'vertical-swing'
|
'on', 'fan-level', 'horizontal-swing', 'vertical-swing'
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
},
|
||||||
|
'environment': {
|
||||||
|
'required': {},
|
||||||
|
'optional': {
|
||||||
|
'properties': {'temperature'}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'entity': 'bath-heater',
|
'entity': 'bath-heater',
|
||||||
@@ -308,7 +314,7 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
|||||||
},
|
},
|
||||||
'optional': {
|
'optional': {
|
||||||
'properties': {'mode', 'temperature'}
|
'properties': {'mode', 'temperature'}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'optional': {},
|
'optional': {},
|
||||||
@@ -381,6 +387,7 @@ SPEC_SERVICE_TRANS_MAP: dict = {
|
|||||||
},
|
},
|
||||||
'fan-control': 'fan',
|
'fan-control': 'fan',
|
||||||
'ceiling-fan': 'fan',
|
'ceiling-fan': 'fan',
|
||||||
|
'air-fresh': 'fan',
|
||||||
'water-heater': {
|
'water-heater': {
|
||||||
'required': {
|
'required': {
|
||||||
'properties': {
|
'properties': {
|
||||||
@@ -400,14 +407,27 @@ SPEC_SERVICE_TRANS_MAP: dict = {
|
|||||||
},
|
},
|
||||||
'optional': {
|
'optional': {
|
||||||
'properties': {
|
'properties': {
|
||||||
'motor-control', 'status', 'current-position', 'target-position'
|
'status', 'current-position', 'target-position'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'entity': 'cover'
|
'entity': 'cover'
|
||||||
},
|
},
|
||||||
'window-opener': 'curtain',
|
'window-opener': 'curtain',
|
||||||
'motor-controller': 'curtain',
|
'motor-controller': 'curtain',
|
||||||
'airer': 'curtain'
|
'airer': 'curtain',
|
||||||
|
'air-conditioner': {
|
||||||
|
'required': {
|
||||||
|
'properties': {
|
||||||
|
'on': {'read', 'write'},
|
||||||
|
'mode': {'read', 'write'},
|
||||||
|
'target-temperature': {'read', 'write'}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'optional': {
|
||||||
|
'properties': {'target-humidity'}
|
||||||
|
},
|
||||||
|
'entity': 'air-conditioner'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"""SPEC_PROP_TRANS_MAP
|
"""SPEC_PROP_TRANS_MAP
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ class Number(MIoTPropertyEntity, NumberEntity):
|
|||||||
if self.spec.external_unit:
|
if self.spec.external_unit:
|
||||||
self._attr_native_unit_of_measurement = self.spec.external_unit
|
self._attr_native_unit_of_measurement = self.spec.external_unit
|
||||||
# Set icon
|
# Set icon
|
||||||
if self.spec.icon:
|
if self.spec.icon and not self.device_class:
|
||||||
self._attr_icon = self.spec.icon
|
self._attr_icon = self.spec.icon
|
||||||
# Set value range
|
# Set value range
|
||||||
if self._value_range:
|
if self._value_range:
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class Sensor(MIoTPropertyEntity, SensorEntity):
|
|||||||
if spec.state_class:
|
if spec.state_class:
|
||||||
self._attr_state_class = spec.state_class
|
self._attr_state_class = spec.state_class
|
||||||
# Set icon
|
# Set icon
|
||||||
if spec.icon:
|
if spec.icon and not self.device_class:
|
||||||
self._attr_icon = spec.icon
|
self._attr_icon = spec.icon
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
Reference in New Issue
Block a user