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

Make simulators return localhost address for info query #1657

Merged
merged 1 commit into from
Jan 8, 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
4 changes: 2 additions & 2 deletions miio/devtools/simulators/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from hashlib import md5


def create_info_response(model, mac):
def create_info_response(model, addr, mac):
"""Create a response for miIO.info call using the given model and mac."""
INFO_RESPONSE = {
"ap": {"bssid": "FF:FF:FF:FF:FF:FF", "rssi": -68, "ssid": "network"},
Expand All @@ -15,7 +15,7 @@ def create_info_response(model, mac):
"model": model,
"netif": {
"gw": "192.168.xxx.x",
"localIp": "192.168.xxx.x",
"localIp": addr,
"mask": "255.255.255.0",
},
"ot": "otu",
Expand Down
2 changes: 1 addition & 1 deletion miio/devtools/simulators/miiosimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async def main(dev):

_ = MiioSimulator(dev=dev, server=server)
mac = mac_from_model(dev._model)
server.add_method("miIO.info", create_info_response(dev._model, mac))
server.add_method("miIO.info", create_info_response(dev._model, "127.0.0.1", mac))

transport, proto = await server.start()

Expand Down
4 changes: 2 additions & 2 deletions miio/devtools/simulators/miotsimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ async def main(dev, model):

mac = mac_from_model(model)
simulator = MiotSimulator(device_model=dev)
server.add_method("miIO.info", create_info_response(model, mac))
server.add_method("miIO.info", create_info_response(model, "127.0.0.1", mac))
server.add_method("action", simulator.action)
server.add_method("get_properties", simulator.get_properties)
server.add_method("set_properties", simulator.set_properties)
Expand All @@ -215,7 +215,7 @@ def miot_simulator(file, model):
else:
cloud = MiotCloud()
# TODO: fix HACK
dev = SimulatedDeviceModel.parse_raw(cloud.get_model_schema(model))
dev = SimulatedDeviceModel.parse_obj(cloud.get_model_schema(model))

loop = asyncio.get_event_loop()
random.seed(1) # nosec
Expand Down