mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-17 07:10:44 +08:00
Compare commits
5 Commits
accf48e09a
...
e2c565cdd0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2c565cdd0 | ||
|
|
739998211e | ||
|
|
ec833b6539 | ||
|
|
f2200ba003 | ||
|
|
073cdf2dcb |
@ -70,8 +70,8 @@ async def async_setup_entry(
|
||||
for miot_device in device_list:
|
||||
if miot_device.miot_client.display_binary_bool:
|
||||
for prop in miot_device.prop_list.get('binary_sensor', []):
|
||||
new_entities.append(BinarySensor(
|
||||
miot_device=miot_device, spec=prop))
|
||||
new_entities.append(
|
||||
BinarySensor(miot_device=miot_device, spec=prop))
|
||||
|
||||
if new_entities:
|
||||
async_add_entities(new_entities)
|
||||
@ -90,7 +90,7 @@ class BinarySensor(MIoTPropertyEntity, BinarySensorEntity):
|
||||
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
|
||||
return bool(self._value) is False
|
||||
elif self.spec.name == 'occupancy-status':
|
||||
return bool(self._value)
|
||||
return self._value is True
|
||||
|
||||
@ -1374,10 +1374,13 @@ class MIoTClient:
|
||||
"""Update cloud devices.
|
||||
NOTICE: This function will operate the cloud_list
|
||||
"""
|
||||
# MIoT cloud service may not publish the online state updating message
|
||||
# MIoT cloud may not publish the online state updating message
|
||||
# for the BLE device. Assume that all BLE devices are online.
|
||||
# MIoT cloud does not publish the online state updating message for the
|
||||
# child device under the proxy gateway (eg, VRF air conditioner
|
||||
# controller). Assume that all proxy gateway child devices are online.
|
||||
for did, info in cloud_list.items():
|
||||
if did.startswith('blt.'):
|
||||
if did.startswith('blt.') or did.startswith('proxy.'):
|
||||
info['online'] = True
|
||||
for did, info in self._device_list_cache.items():
|
||||
if filter_dids and did not in filter_dids:
|
||||
|
||||
@ -998,9 +998,11 @@ class MipsCloudClient(_MipsClient):
|
||||
did, MIoTDeviceState.ONLINE if msg['event'] == 'online'
|
||||
else MIoTDeviceState.OFFLINE, ctx)
|
||||
|
||||
if did.startswith('blt.'):
|
||||
# MIoT cloud may not publish BLE device online/offline state message.
|
||||
# Do not subscribe BLE device online/offline state.
|
||||
if did.startswith('blt.') or did.startswith('proxy.'):
|
||||
# MIoT cloud may not publish BLE device or proxy gateway child device
|
||||
# online/offline state message.
|
||||
# Do not subscribe BLE device or proxy gateway child device
|
||||
# online/offline state.
|
||||
return True
|
||||
return self.__reg_broadcast_external(
|
||||
topic=topic, handler=on_state_msg, handler_ctx=handler_ctx)
|
||||
|
||||
@ -601,7 +601,10 @@ class MIoTSpecProperty(_MIoTSpecBase):
|
||||
if value is None:
|
||||
return None
|
||||
if self.format_ == int:
|
||||
return int(round(value))
|
||||
if self.value_range is None:
|
||||
return int(round(value))
|
||||
return int(
|
||||
round(value / self.value_range.step) * self.value_range.step)
|
||||
if self.format_ == float:
|
||||
return round(value, self.precision)
|
||||
if self.format_ == bool:
|
||||
|
||||
@ -167,11 +167,6 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
||||
},
|
||||
'battery': {
|
||||
'required': {
|
||||
'properties': {
|
||||
'battery-level': {'read'}
|
||||
}
|
||||
},
|
||||
'optional': {
|
||||
'actions': {
|
||||
'start-charge'
|
||||
}
|
||||
|
||||
@ -90,7 +90,6 @@ class Vacuum(MIoTServiceEntity, StateVacuumEntity):
|
||||
# pylint: disable=unused-argument
|
||||
_prop_status: Optional[MIoTSpecProperty]
|
||||
_prop_fan_level: Optional[MIoTSpecProperty]
|
||||
_prop_battery_level: Optional[MIoTSpecProperty]
|
||||
_prop_status_cleaning: Optional[list[int]]
|
||||
_prop_status_docked: Optional[list[int]]
|
||||
_prop_status_paused: Optional[list[int]]
|
||||
@ -117,7 +116,6 @@ class Vacuum(MIoTServiceEntity, StateVacuumEntity):
|
||||
|
||||
self._prop_status = None
|
||||
self._prop_fan_level = None
|
||||
self._prop_battery_level = None
|
||||
self._prop_status_cleaning = []
|
||||
self._prop_status_docked = []
|
||||
self._prop_status_paused = []
|
||||
@ -180,9 +178,6 @@ class Vacuum(MIoTServiceEntity, StateVacuumEntity):
|
||||
self._attr_fan_speed_list = list(self._fan_level_map.values())
|
||||
self._attr_supported_features |= VacuumEntityFeature.FAN_SPEED
|
||||
self._prop_fan_level = prop
|
||||
elif prop.name == 'battery-level':
|
||||
self._attr_supported_features |= VacuumEntityFeature.BATTERY
|
||||
self._prop_battery_level = prop
|
||||
# action
|
||||
for action in entity_data.actions:
|
||||
if action.name == 'start-sweep':
|
||||
@ -251,11 +246,6 @@ class Vacuum(MIoTServiceEntity, StateVacuumEntity):
|
||||
"""Name of the vacuum entity."""
|
||||
return self._device_name
|
||||
|
||||
@property
|
||||
def battery_level(self) -> Optional[int]:
|
||||
"""The current battery level of the vacuum cleaner."""
|
||||
return self.get_prop_value(prop=self._prop_battery_level)
|
||||
|
||||
@property
|
||||
def fan_speed(self) -> Optional[str]:
|
||||
"""The current fan speed of the vacuum cleaner."""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user