GadgetReactor / pyHS100

Python Library to control TPLink Switch (HS100 / HS110)
Other
409 stars 128 forks source link

exception when no emeter #157

Closed ghvader closed 4 years ago

ghvader commented 5 years ago

I know you guys are working on adding HS300 support (i was following along) installed version 0.3.4 today and noticed when i did a state, it worked on my HS300, but when it gets to my HS100 it throws an exception. so i figured i would report that in case it was helpful.

`

pyhs100 state No host name given, trying discovery.. Discovering devices for 3 seconds == TP-LINK_Power Strip - HS300(US) == Device state: ON Host/IP: 192.168.2.21 Plug 5 on since: 2019-01-27 15:48:15.591480 Plug 3 on since: 2019-01-19 22:22:41.591343 Plug 6 on since: 2019-01-12 21:07:56.591538 Plug 1 on since: 2019-01-12 21:07:54.591115 Plug 4 on since: 2019-01-27 15:48:15.591409 Plug 2 on since: 2019-01-27 15:48:15.591277 LED state: True == Generic information == Time: 2019-01-27 10:48:04 Hardware: 1.0 Software: 1.0.6 Build 180627 Rel.081000 MAC (rssi): removed Location: removed == Emeter == == Current State == {0: {'voltage_mv': 122133, 'power_mw': 0, 'current_ma': 4, 'total_wh': 39}, 1: {'voltage_mv': 122100, 'power_mw': 26, 'current_ma': 4, 'total_wh': 0}, 2: {'voltage_mv': 122149, 'power_mw': 53, 'current_ma': 4, 'total_wh': 0}, 3: {'voltage_mv': 122116, 'power_mw': 1, 'current_ma': 4, 'total_wh': 0}, 4: {'voltage_mv': 122116, 'power_mw': 0, 'current_ma': 3, 'total_wh': 0}, 5: {'voltage_mv': 122116, 'power_mw': 3, 'current_ma': 3, 'total_wh': 279}}

== My Smart Plug - HS100(US) == OFF Host/IP: 192.168.2.90 On since: 2019-01-27 15:48:19.456283 LED state: True == Generic information == Time: 2019-01-27 10:48:17 Hardware: 2.0 Software: 1.2.1 Build 170405 Rel.155334 MAC (rssi): removed Location: removed == Emeter == Device has no emeter

Traceback (most recent call last): File "/srv/homeassistant/bin/pyhs100", line 10, in sys.exit(cli()) File "/srv/homeassistant/lib/python3.5/site-packages/click/core.py", line 722, in call return self.main(args, kwargs) File "/srv/homeassistant/lib/python3.5/site-packages/click/core.py", line 697, in main rv = self.invoke(ctx) File "/srv/homeassistant/lib/python3.5/site-packages/click/core.py", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/srv/homeassistant/lib/python3.5/site-packages/click/core.py", line 895, in invoke return ctx.invoke(self.callback, ctx.params) File "/srv/homeassistant/lib/python3.5/site-packages/click/core.py", line 535, in invoke return callback(args, **kwargs) File "/srv/homeassistant/lib/python3.5/site-packages/click/decorators.py", line 63, in new_func % object_type.name) RuntimeError: Managed to invoke callback without a context object of type 'SmartDevice' existing

`

rytilahti commented 5 years ago

Could you test if this is still the case with the current master? #177 added a fix to cli with hs300, but it wasn't about emeter so I'm not sure if the emeter problem is there anymore after the big refactoring took place.

ghvader commented 5 years ago

@rytilahti still an issue with .3.5 (worse actually) it bombs out right away instead of getting some info

$ /srv/homeassistant/bin/pyhs100 state
No host name given, trying discovery..
Discovering devices for 3 seconds
Traceback (most recent call last):
  File "/srv/homeassistant/bin/pyhs100", line 10, in <module>
    sys.exit(cli())
  File "/srv/homeassistant/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/srv/homeassistant/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/srv/homeassistant/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/srv/homeassistant/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.7/site-packages/click/decorators.py", line 63, in new_func
    % object_type.__name__)
RuntimeError: Managed to invoke callback without a context object of type 'SmartDevice' existing`
rytilahti commented 4 years ago

We are closing this repository for new changes in favor of a new, asyncio-enabled continuation project: https://github.com/python-kasa/python-kasa

If the issue is still present in the new project, please feel free to open an issue there, thanks!