ericpignet / home-assistant-tplink_router

TPLink router device tracker for Home Assistant
41 stars 28 forks source link

Device/support request: Deco M9 Plus #9

Closed Ron168 closed 4 years ago

Ron168 commented 4 years ago

Hi there,

thanks a lot for developing this plugin. Unfortunately isn't my router supported (yet). I'm a software developer and can probably get it to work myself after a lot of trial and error. I'm hoping you can give me a push into the right direction, so I can make this plugin work for my router and so others can benefit from this as well.

This is was I got in my log: 2020-06-23 21:26:10 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for tplink_router which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant. 2020-06-23 21:26:15 ERROR (SyncWorker_0) [custom_components.tplink_router.device_tracker] AP didn't respond with JSON. Check if credentials are correct 2020-06-23 21:26:15 ERROR (SyncWorker_0) [custom_components.tplink_router.device_tracker] Error 404 from router 2020-06-23 21:26:16 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform legacy Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/device_tracker/setup.py", line 64, in async_setup_legacy self.platform.get_scanner, hass, {DOMAIN: self.config} File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/tplink_router/device_tracker.py", line 56, in get_scanner scanner = cls(config[DOMAIN]) File "/config/custom_components/tplink_router/device_tracker.py", line 237, in init super(C9TplinkDeviceScanner, self).init(config) File "/config/custom_components/tplink_router/device_tracker.py", line 83, in init self.success_init = self._update_info() File "/config/custom_components/tplink_router/device_tracker.py", line 285, in _update_info self._get_auth_tokens() File "/config/custom_components/tplink_router/device_tracker.py", line 266, in _get_auth_tokens self.stok = response.json().get('data').get('stok') AttributeError: 'str' object has no attribute 'get'

Please let me know if I can provide you with something else.

Thanks in advance for your help.

Ron

ericpignet commented 4 years ago

Hi Ron,

You can modify the code for the plugin directly in your config directory, even if it's installed via HACS. File is custom_components/tplink_router/device_tracker folder.py I would recommend making sure that you have debug logs, at least for this plugin, then add AttributeError line 273 to catch the error and continue the detection process instead of failing (I will also add this and release a new minor version)

Then the rest of the detection didn't work, it means your router is not supported. I would start by opening the admin UI, going to the page where all devices are listed, use browser dev tools to see what query is made to server, see if any other scanner in the plugin is using a similar query and adapt to your router.

Eric

Ron168 commented 4 years ago

Hi Eric,

Thanks a lot for your quick and helpful reply. I already figured out I could edit the files, but didn't really understand where everything was logged, now I do. Thanks. What I'm struggling with now, is using the dev tools. I don't get, or don't see, any token being generated. Suddenly, in one of the next requests, the token is there. My login screen only contains a password field, no username field. Any suggestions on how to figure out how to get the token? One I've that, I'm pretty confident I'll manage to get the IP addresses. Regarding that, I've 3 access points. Any experience with getting the connected devices per access point?

Thanks in advance for your help!

Best regards, Ron