Skip to content

Commit

Permalink
Fix broken miio-simulator start-up
Browse files Browse the repository at this point in the history
This fixes a regression introduced in #1710 where the device object was passed to the did_and_mac_for_model instead of the expected model name.
  • Loading branch information
rytilahti committed Jul 14, 2023
1 parent d4ca76e commit ef11774
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions miio/devtools/simulators/miiosimulator.py
Expand Up @@ -90,10 +90,6 @@ def __init__(self, dev: SimulatedMiio, server: PushServer):
self._setters = {}
self._server = server

# If no model is given, use one from the supported ones
if self._dev._model is None:
self._dev._model = next(iter(self._dev.models)).model

# Add get_prop if device has properties defined
if self._dev.properties:
server.add_method("get_prop", self.get_prop)
Expand Down Expand Up @@ -135,7 +131,13 @@ def handle_set(self, payload):


async def main(dev):
did, mac = did_and_mac_for_model(dev)
if dev._model is None:
dev._model = next(iter(dev.models)).model
_LOGGER.warning(

Check warning on line 136 in miio/devtools/simulators/miiosimulator.py

View check run for this annotation

Codecov / codecov/patch

miio/devtools/simulators/miiosimulator.py#L135-L136

Added lines #L135 - L136 were not covered by tests
"No --model defined, using the first supported one: %s", dev._model
)

did, mac = did_and_mac_for_model(dev._model)

Check warning on line 140 in miio/devtools/simulators/miiosimulator.py

View check run for this annotation

Codecov / codecov/patch

miio/devtools/simulators/miiosimulator.py#L140

Added line #L140 was not covered by tests
server = PushServer(device_id=did)

_ = MiioSimulator(dev=dev, server=server)
Expand Down

0 comments on commit ef11774

Please sign in to comment.