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

Obtain token for given IP address #263

Closed
sedrubal opened this issue Mar 13, 2018 · 2 comments
Closed

Obtain token for given IP address #263

sedrubal opened this issue Mar 13, 2018 · 2 comments

Comments

@sedrubal
Copy link

As far as I see there is no command line option to obtain the token for a device with a specific IP address by just sending the special UDP package (21310020ff...) to port 54321 and extract the token.
Here are some hacky lines to extend the discover option, which should do the job but are not good enough for a pull request 😉:

  @cli.command()
  @click.option('--handshake', type=bool, default=False)
+ @click.option('--ip', envvar="MIROBO_IP", callback=validate_ip)
  def discover(handshake, ip):
      """Search for robots in the network."""
+     if ip:
+         vac = miio.Vacuum(ip)
+         m = vac.do_discover()
+         import binascii
+         import codecs
+         _LOGGER.info("  IP %s (ID: %s) - token: %s",
+                      ip,
+                      binascii.hexlify(m.header.value.device_id).decode(),
+                      codecs.encode(m.checksum, 'hex'))
+         return

    if handshake:
        miio.Vacuum.discover()
    else:
        miio.Discovery.discover_mdns()

P. S.: Thanks for your project.

@rytilahti
Copy link
Owner

The handshake handling could really use some cleaning up to make it also nicer for external use, there is #152 which goes towards this direction and we are open for PRs to make it happen :-)

@rytilahti
Copy link
Owner

To clean up the open issues, I'm closing this in favor of #152.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants