Skip to content

Commit

Permalink
Suppress 'found an unsupported model' warning (#1850)
Browse files Browse the repository at this point in the history
This is not needed anymore, as #1845 reports on missing identifiers and
roborocks are covered by a wildcard matcher in devicefactory.

The original reason for adding this warning was to gather a list of
devices that we should add to the supported devices list for
devicefactory, but I think we are well covered now at least for roborock
(closing the issues below, other integrations need to be adapted to use
wildcards where feasible).
  • Loading branch information
rytilahti committed Oct 23, 2023
1 parent 4e2c5ee commit 9b17d90
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
9 changes: 0 additions & 9 deletions miio/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,6 @@ def _fetch_info(self) -> DeviceInfo:
devinfo = DeviceInfo(self.send("miIO.info"))
self._info = devinfo
_LOGGER.debug("Detected model %s", devinfo.model)
cls = self.__class__.__name__
# Ignore bases and generic classes
bases = ["Device", "MiotDevice", "GenericMiot"]
if devinfo.model not in self.supported_models and cls not in bases:
_LOGGER.warning(
"Found an unsupported model '%s' for class '%s'. If this is working for you, please open an issue at https://github.com/rytilahti/python-miio/",
devinfo.model,
cls,
)

return devinfo
except PayloadDecodeException as ex:
Expand Down
19 changes: 0 additions & 19 deletions miio/tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
DeviceStatus,
MiotDevice,
PropertyDescriptor,
RoborockVacuum,
)
from miio.exceptions import DeviceInfoUnavailableException, PayloadDecodeException

Expand Down Expand Up @@ -120,24 +119,6 @@ def test_forced_model(mocker):
info.assert_not_called()


@pytest.mark.parametrize(
"cls,hidden", [(Device, True), (MiotDevice, True), (RoborockVacuum, False)]
)
def test_missing_supported(mocker, caplog, cls, hidden):
"""Make sure warning is logged if the device is unsupported for the class."""
_ = mocker.patch("miio.Device.send")

d = cls("127.0.0.1", "68ffffffffffffffffffffffffffffff")
d._fetch_info()

if hidden:
assert "Found an unsupported model" not in caplog.text
assert f"for class {cls.__name__!r}" not in caplog.text
else:
assert "Found an unsupported model" in caplog.text
assert f"for class {cls.__name__!r}" in caplog.text


@pytest.mark.parametrize("cls", DEVICE_CLASSES)
def test_device_ctor_model(cls):
"""Make sure that every device subclass ctor accepts model kwarg."""
Expand Down

0 comments on commit 9b17d90

Please sign in to comment.