10000 HS107 Support · Issue #37 · python-kasa/python-kasa · GitHub
[go: up one dir, main page]

Skip to content

HS107 Support #37

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

Closed
acmay opened this issue Apr 10, 2020 · 6 comments
Closed

HS107 Support #37

acmay opened this issue Apr 10, 2020 · 6 comments

Comments

@acmay
Copy link
Contributor
acmay commented Apr 10, 2020

https://www.kasasmart.com/us/products/smart-plugs/kasa-smart-wi-fi-plug-2-outlets-hs107

I have one of these devices and the library crashes on the get_realtime emeter.

Here are some trimmed down logs.

DEBUG:kasa.protocol:> (33) {"system": {"get_sysinfo": null}}
DEBUG:kasa.protocol:< (705) {"system":{"get_sysinfo":{"sw_ver":"1.0.8 Build 190103 Rel.163436","hw_ver":"1.0","model":"HS107(US)","deviceId":"XXX","oemId":"XXX","hwId":"XX","rssi":-56,"longitude_i":XX,"latitude_i":XXX,"alias":"TP-LINK_Smart Plug_C119","mic_type":"IOT.SMARTPLUGSWITCH","feature":"TIM","mac":"XXX","updating":0,"led_off":0,"children":[{"id":"XXX","state":0,"alias":"Two head","on_time":0,"next_action":{"type":-1}},{"id":"XXX","state":0,"alias":"Tree","on_time":0,"next_action":{"type":-1}}],"child_num":2,"err_code":0}}}
DEBUG:kasa.smartstrip:Initializing 2 child sockets
DEBUG:kasa.smartdevice:Initializing XXX with cache ttl 0:00:03
DEBUG:kasa.smartdevice:Initializing XXX with cache ttl 0:00:03
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:kasa.smartdevice:Checking cache for system get_sysinfo
DEBUG:kasa.smartdevice:Got cached system get_sysinfo
== TP-LINK_Smart Plug_C119 - HS107(US) ==
Device state: OFF
DEBUG:asyncio:Using selector: EpollSelector
WARNING:kasa.smartstrip:You called update() on a child device, which has no effect.Call update() on the parent device instead.
  * Two head state: OFF
DEBUG:asyncio:Using selector: EpollSelector
WARNING:kasa.smartstrip:You called update() on a child device, which has no effect.Call update() on the parent device instead.
  * Tree state: OFF
Host/IP: XXXXXXXXX
LED state: True
== Generic information ==
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:kasa.smartdevice:Checking cache for time get_time
DEBUG:kasa.smartdevice:Got no result from cache, querying the device.
DEBUG:kasa.protocol:> (28) {"time": {"get_time": null}}
DEBUG:kasa.protocol:< (96) {"time":{"get_time":{"year":2020,"month":4,"mday":10,"hour":14,"min":49,"sec":49,"err_code":0}}}
Time:         2020-04-10 14:49:49
Hardware:     1.0
Software:     1.0.8 Build 190103 Rel.163436
MAC (rssi):   XXXXXX (XX)
Location:     {'latitude': XXXXXXX, 'longitude': XXXXXXXX}
== Emeter ==
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:kasa.smartdevice:Checking cache for system get_sysinfo
DEBUG:kasa.smartdevice:Got cached system get_sysinfo
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:kasa.smartdevice:Checking cache for emeter get_realtime
DEBUG:kasa.smartdevice:Got no result from cache, querying the device.
DEBUG:kasa.protocol:> (34) {"emeter": {"get_realtime": null}}
DEBUG:kasa.protocol:< (57) {"emeter":{"err_code":-1,"err_msg":"module not support"}}
Traceback (most recent call last):
  File "kasa/cli.py", line 390, in <module>
    cli()
  File "/home/acmay/.local/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/acmay/.local/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/acmay/.local/lib/python3.7/site-packages/click/core.py", line 1236, in invoke
    return Command.invoke(self, ctx)
  File "/home/acmay/.local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/acmay/.local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/acmay/.local/lib/python3.7/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "kasa/cli.py", line 63, in cli
    ctx.invoke(discover)
  File "/home/acmay/.local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/acmay/.local/lib/python3.7/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "kasa/cli.py", line 146, in discover
    ctx.invoke(state)
  File "/home/acmay/.local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/acmay/.local/lib/python3.7/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/acmay/.local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/acmay/.local/lib/python3.7/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "kasa/cli.py", line 214, in state
    ctx.invoke(emeter)
  File "/home/acmay/.local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/acmay/.local/lib/python3.7/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/acmay/.local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "kasa/cli.py", line 272, in emeter
    emeter_status = asyncio.run(dev.get_emeter_realtime())
  File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/home/acmay/src/hass/python-kasa/kasa/smartdevice.py", line 89, in wrapped
    return await f(*args, **kwargs)
  File "/home/acmay/src/hass/python-kasa/kasa/smartdevice.py", line 456, in get_emeter_realtime
    return EmeterStatus(await self._query_helper(self.emeter_type, "get_realtime"))
  File "/home/acmay/src/hass/python-kasa/kasa/smartdevice.py", line 188, in _query_helper
    raise SmartDeviceException(f"Error on {target}.{cmd}: {result}")
kasa.smartdevice.SmartDeviceException: Error on emeter.get_realtime: {'err_code': -1, 'err_msg': 'module not support'}
@rytilahti
Copy link
Member

Looks like the device does not support power monitoring, is that also the case with the app? If yes, then we need to exclude it from devices supporting monitoring (which I assumed was the case on all multi-socket devices).

@acmay
Copy link
Contributor Author
acmay commented Apr 10, 2020

Correct no power readings just on time. I don't have a kasa plug with the power readings to know what it looks like in the app.
I was able to hack smartstrip.py to return false on the has_emeter() to get further.

I have a KP400 as well with the same problem but it has an additional issue that it seems to return 0 data on the sysinfo most of the time. It is outside so it is on the far side of my range. But I would think that is a separate issue.

@rytilahti
Copy link
Member

Ok, the code needs to be adapted to do a model check to fix that, thanks for testing and reporting back!

On the KP400 issue, that's worth creating a separate issue (if #38 is not exactly that).

@acmay
Copy link
Contributor Author
acmay commented Apr 10, 2020

Yes, #38 is the other issue for the empty data response.
I would think KP400 support in general on an easy network would fall ok under this one but it could be yet a 3rd issue.

@rytilahti
Copy link
Member

Ok. Could you do kasa dump-discover and create a PR to add the fixture file for KP400 to https://github.com/python-kasa/python-kasa/tree/master/kasa/tests/fixtures (and updating the README.md also accordingly :-))?

@rytilahti
Copy link
Member

I think this is now fixed in master, thanks for reporting!

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
0