Initial support for vacuums (clean module) (#944)

Adds support for clean module:
- Show current vacuum state
- Start cleaning (all rooms)
- Return to dock
- Pausing & unpausing
- Controlling the fan speed

---------

Co-authored-by: Steven B <51370195+sdb9696@users.noreply.github.com>
This commit is contained in:
Teemu R.
2025-01-14 15:35:09 +01:00
committed by GitHub
parent be34dbd387
commit 1be87674bf
16 changed files with 799 additions and 13 deletions

View File

@@ -134,7 +134,14 @@ async def test_discover_single(discovery_mock, custom_port, mocker):
discovery_mock.ip = host
discovery_mock.port_override = custom_port
device_class = Discover._get_device_class(discovery_mock.discovery_data)
disco_data = discovery_mock.discovery_data
device_class = Discover._get_device_class(disco_data)
http_port = (
DiscoveryResult.from_dict(disco_data["result"]).mgt_encrypt_schm.http_port
if "result" in disco_data
else None
)
# discovery_mock patches protocol query methods so use spy here.
update_mock = mocker.spy(device_class, "update")
@@ -143,7 +150,11 @@ async def test_discover_single(discovery_mock, custom_port, mocker):
)
assert issubclass(x.__class__, Device)
assert x._discovery_info is not None
assert x.port == custom_port or x.port == discovery_mock.default_port
assert (
x.port == custom_port
or x.port == discovery_mock.default_port
or x.port == http_port
)
# Make sure discovery does not call update()
assert update_mock.call_count == 0
if discovery_mock.default_port == 80:
@@ -153,6 +164,7 @@ async def test_discover_single(discovery_mock, custom_port, mocker):
discovery_mock.device_type,
discovery_mock.encrypt_type,
discovery_mock.login_version,
discovery_mock.https,
)
config = DeviceConfig(
host=host,
@@ -681,7 +693,7 @@ async def test_discover_try_connect_all(discovery_mock, mocker):
and self._transport.__class__ is transport_class
):
return discovery_mock.query_data
raise KasaException()
raise KasaException("Unable to execute query")
async def _update(self, *args, **kwargs):
if (
@@ -689,7 +701,8 @@ async def test_discover_try_connect_all(discovery_mock, mocker):
and self.protocol._transport.__class__ is transport_class
):
return
raise KasaException()
raise KasaException("Unable to execute update")
mocker.patch("kasa.IotProtocol.query", new=_query)
mocker.patch("kasa.SmartProtocol.query", new=_query)