Skip to content

Obtain token for given IP address #263

Closed
@sedrubal

Description

@sedrubal

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions