mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-20 17:29:38 +08:00
Compare commits
2 Commits
0f65635342
...
f2200ba003
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2200ba003 | ||
|
|
073cdf2dcb |
@ -70,8 +70,8 @@ async def async_setup_entry(
|
|||||||
for miot_device in device_list:
|
for miot_device in device_list:
|
||||||
if miot_device.miot_client.display_binary_bool:
|
if miot_device.miot_client.display_binary_bool:
|
||||||
for prop in miot_device.prop_list.get('binary_sensor', []):
|
for prop in miot_device.prop_list.get('binary_sensor', []):
|
||||||
new_entities.append(BinarySensor(
|
new_entities.append(
|
||||||
miot_device=miot_device, spec=prop))
|
BinarySensor(miot_device=miot_device, spec=prop))
|
||||||
|
|
||||||
if new_entities:
|
if new_entities:
|
||||||
async_add_entities(new_entities)
|
async_add_entities(new_entities)
|
||||||
@ -90,7 +90,7 @@ class BinarySensor(MIoTPropertyEntity, BinarySensorEntity):
|
|||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""On/Off state. True if the binary sensor is on, False otherwise."""
|
"""On/Off state. True if the binary sensor is on, False otherwise."""
|
||||||
if self.spec.name == 'contact-state':
|
if self.spec.name == 'contact-state':
|
||||||
return self._value is False
|
return bool(self._value) is False
|
||||||
elif self.spec.name == 'occupancy-status':
|
elif self.spec.name == 'occupancy-status':
|
||||||
return bool(self._value)
|
return bool(self._value)
|
||||||
return self._value is True
|
return self._value is True
|
||||||
|
|||||||
@ -601,7 +601,10 @@ class MIoTSpecProperty(_MIoTSpecBase):
|
|||||||
if value is None:
|
if value is None:
|
||||||
return None
|
return None
|
||||||
if self.format_ == int:
|
if self.format_ == int:
|
||||||
|
if self.value_range is None:
|
||||||
return int(round(value))
|
return int(round(value))
|
||||||
|
return int(
|
||||||
|
round(value / self.value_range.step) * self.value_range.step)
|
||||||
if self.format_ == float:
|
if self.format_ == float:
|
||||||
return round(value, self.precision)
|
return round(value, self.precision)
|
||||||
if self.format_ == bool:
|
if self.format_ == bool:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user