Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress 'found an unsupported model' warning #1850

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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