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

miplug discover throws exception #339

Closed
ghost opened this issue Jun 16, 2018 · 4 comments
Closed

miplug discover throws exception #339

ghost opened this issue Jun 16, 2018 · 4 comments

Comments

@ghost
Copy link

ghost commented Jun 16, 2018

Running miplug discover results in exception:

miplug discover
Traceback (most recent call last):
  File "/home/pi/.local/bin/miplug", line 11, in <module>
    sys.exit(cli())
  File "/home/pi/.local/lib/python3.5/site-packages/miio/click_common.py", line 53, in __call__
    return self.main(*args, **kwargs)
  File "/home/pi/.local/lib/python3.5/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/pi/.local/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/pi/.local/lib/python3.5/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/pi/.local/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/pi/.local/lib/python3.5/site-packages/miio/plug_cli.py", line 50, in discover
    miio.Plug.discover()
AttributeError: 'function' object has no attribute 'discover'

Same error happens on android (termux, python 3.6.5), raspberry pi (Python 3.5.3), and macos (Python 3.6.5).

I tried removing the released pip version and installed instead from master with

pip3 install git+https://github.com/rytilahti/python-miio

but still getting the same error.

Reproducible with current master: fb595be

@rytilahti
Copy link
Owner

rytilahti commented Jun 17, 2018

You should prefer the miiocli command as miplug is deprecated, see miiocli plug --help for help.

Regarding to this issue, I took a peek and to my understanding miio.Plug is not a function but a class -- @syssi, do you have an idea why this is happening?

edit: Actually checking it again, it seems obvious that the deprecated decorator causes this problem, but what's the best way to fix it is unknown.

@ghost
Copy link
Author

ghost commented Jun 17, 2018

@rytilahti: miiocli plug does not have a discover option. Does it mean it has been removed?

I currently have to rely on arp -an | grep <mac-address> to get the IP of the plug. I was hoping I could get this info from discover. Is there some other way to find the IP? Since it is assigned via DHCP it keeps changing so I cannot hardcode it, also cannot configure a permanent IP for the MAC address since my router does not provide this feature.

Also, I seem to be getting incomplete output from miiocli:

# miiocli plug --token <PLUG_TOKEN> --ip 192.168.1.100 status
Power: True
USB Power: None
Temperature: 41 °C
Load power: None
WiFi LED: None

Both USB power and main power are on, but miiocli plug only shows the value for Power. Is this a bug or am I missing something? (if you can confirm this is bug then I'll clean up this thread and file another defect.)

@syssi
Copy link
Collaborator

syssi commented Jun 18, 2018

Both are missing features of the miiocli. It should be possible to select the correct device model at the CLI and we should provide the discover feature. Please create two additional issues. Thanks for your support!

syssi added a commit to syssi/python-miio that referenced this issue Jun 18, 2018
@ghost
Copy link
Author

ghost commented Jun 18, 2018

@syssi: created the following issues:
#344: miiocli plug does not show the USB power status
#345: miiocli plug does not have a discover option

@syssi syssi closed this as completed in 834bcb3 Jun 20, 2018
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