mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add missing moisture sensor to xiaomi_ble (#78160)
This commit is contained in:
parent
0227f2cd67
commit
28f4a5b7a2
@ -39,6 +39,9 @@ BINARY_SENSOR_DESCRIPTIONS = {
|
|||||||
key=XiaomiBinarySensorDeviceClass.SMOKE,
|
key=XiaomiBinarySensorDeviceClass.SMOKE,
|
||||||
device_class=BinarySensorDeviceClass.SMOKE,
|
device_class=BinarySensorDeviceClass.SMOKE,
|
||||||
),
|
),
|
||||||
|
XiaomiBinarySensorDeviceClass.MOISTURE: BinarySensorEntityDescription(
|
||||||
|
key=XiaomiBinarySensorDeviceClass.MOISTURE,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,3 +52,48 @@ async def test_smoke_sensor(hass):
|
|||||||
|
|
||||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
||||||
|
async def test_moisture(hass):
|
||||||
|
"""Make sure that formldehyde sensors are correctly mapped."""
|
||||||
|
entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN,
|
||||||
|
unique_id="C4:7C:8D:6A:3E:7A",
|
||||||
|
)
|
||||||
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
|
saved_callback = None
|
||||||
|
|
||||||
|
def _async_register_callback(_hass, _callback, _matcher, _mode):
|
||||||
|
nonlocal saved_callback
|
||||||
|
saved_callback = _callback
|
||||||
|
return lambda: None
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
"homeassistant.components.bluetooth.update_coordinator.async_register_callback",
|
||||||
|
_async_register_callback,
|
||||||
|
):
|
||||||
|
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert len(hass.states.async_all()) == 0
|
||||||
|
|
||||||
|
# WARNING: This test data is synthetic, rather than captured from a real device
|
||||||
|
# obj type is 0x1014, payload len is 0x2 and payload is 0xf400
|
||||||
|
saved_callback(
|
||||||
|
make_advertisement(
|
||||||
|
"C4:7C:8D:6A:3E:7A", b"q \x5d\x01iz>j\x8d|\xc4\r\x14\x10\x02\xf4\x00"
|
||||||
|
),
|
||||||
|
BluetoothChange.ADVERTISEMENT,
|
||||||
|
)
|
||||||
|
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
assert len(hass.states.async_all()) == 1
|
||||||
|
|
||||||
|
sensor = hass.states.get("binary_sensor.smart_flower_pot_6a3e7a_moisture")
|
||||||
|
sensor_attr = sensor.attributes
|
||||||
|
assert sensor.state == "on"
|
||||||
|
assert sensor_attr[ATTR_FRIENDLY_NAME] == "Smart Flower Pot 6A3E7A Moisture"
|
||||||
|
|
||||||
|
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user