-
Notifications
You must be signed in to change notification settings - Fork 5
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
Support DSP-W115? #1
Comments
Based on the output it appears as if your device is paired with the mydlink app. Is this correct? If so, have you aquired the device token that is stored on the device itself? If you have, you should replace the line |
Some other points.
If you find that the program works for your device I'd be interested to know. If you create any improvements to the program at all, I'll be more than happy to include them.
I reverse engineered the binary responsible for the server found on port 8080 and 8081 (the binary is called da_adaptor). As far as I can tell they are using their own protocol. Although part of the traffic is parsed using HybiParser (as can be seen in the code). The HNAP1 protocol is no longer in use and will respond with generic messages to all request such as "This command does not exist" or something similar (I cannot remember the exact wording).
Your computer holds a set of trusted certificates when connecting to SSL services. The certificate used by the plug is not covered by this list, as such the browser will not connect to it, although this is not an issue with the script.
There is no graphical web interface. |
Thanks for the fast response.
Yes, this is the case. Was this a mistake?
How can I aquire the device token? Can I see it in the app somewhere? I will sure let you know if I get it working. |
Have a look at the README under "Usage", if you have any questions about the instructions there, just ask.
As far as I know you can only get this from the device itself. Although it's not impossible that it can be obtained through D-Link in some way, I'm just not aware as to how. |
Uhhh... sorry, I must have missed that part about the device ID when skimming through Usage earlier. Ok, I now got some results. Then I tried it without setting it up in the app (I did not do the last step in the app after the DSP-W115 connected to my wifi) with Pin=000000. That did not work. Did I understand it correctly that it should work in that way (or works on the DSP-W245)? Then I completed the setup and extracted the device_token with that I can talk to the DSP-W115, switch the socket and enable / disable the LED (but both commands set_socket and set_led to both actions at the same time, is that correct?) I get some exceptions, though. On keepAlive and on set_socket(1, True/False) I get this error:
|
I agree that the instructions could be made a bit more clear.
The pin code is always what it says on the back of the device (so it should not be 000000). It will not change if you reset the device. Other than that it should work as long as the device is connected to the WiFi but not the app.
Yes. They are identical.
Hmm. I'm not sure what's causing the error. It could be due to the models being slighly different. The error handling is mostly put in place to detect issues when setting everything up, so you could potentially remove lines 247 to 249 (including) to get around it as the communication looks ok otherwise(?). |
Yes, communication was good already. Without the lines you mentioned the exception goes away and I can switch the socket multiple times. Great work. Thank you very much for your support. So you can report the dsp W115 working, I'd say. |
Glad to hear you got it working! |
I found out a bit more, maybe you are interested in that, too. I am no python developer and low on sparetime, too, so I won't augment this library... would take me too long and I'd make to many mistakes. My goal is to add support for those plugs in ioBroker, which is a node.js based smarthome middleware. So I build a node.js library from what you found out here: https://github.com/Garfonso/dlinkWebSocketClient I noticed that the device token (i.e. what you need if connected to the app) changes on every reboot... luckily the telnet stays open, so you can easily get it again. But that is not optimal. I have to dig a bit more, there... Also I added the function get_settings with just the "type": 16 parameter it returns the current settings (for DSP-W115 I get an array with one entry, so I assume for DSP-W245 you'll get the state of all four sockets? Maybe you can give that a try. But maybe you hate to supply it an array with multiple settings and get as many back? Not sure. I do not need to supply the index in get_setting, though). Thank you very much for all the work done which I could build upon. |
Yea I noticed your library by pure chance 2 minutes after you made a commit to it. I can't tell you how glad I am that you found my library useful! Interesting. I was aware that the token changed when the device was reset, but I was not aware that it changed during normal reboots. I rarley rebooted my device, however, so it's possible I never ran into that. There are a bunch of extra commands you can send the device. Since I had no use for any of the other commands, I never bothered to implement them. Initially I was never planning on releasing this library but I thought that someone might get some use out of it so I just released it more or less as it was. If you have any questions about the device itself (architecture, code, authentication, etc.) feel free to ask while my memory of it is still somewhat fresh. |
Do you happen to have a list or something? (I tried to dig a bit, but my knowledge in this area is pretty restricted. I basically only had a look at the string constants in the da_adaptor binary - but it is next to impossible to determine the parameters that way). |
Here is a list of possible commands that you can send. I'm not sure if they will all work, but they are present in the code atleast. I also noticed that
|
I used Ghidra to reverse engineer the binary. It was a slow process since it was the first time I did something like this. Ghidra will provide an approximate decompilation of the binary in C, which helped a lot. The main function of interest that handles sent requests (after upgrading from HTTP to the JSON based protocol) is called |
Do you maybe happen to know a function that returns the model of the device? Could not find anything... |
You could use the webserver present on the device http://192.168.0.20/login?username=Admin&password=PIN. The user name is "Admin" (case sensitive) and the password is your pin code.
If I remember correctly the last four characters are from the MAC address, so you could just remove those. I am unaware of any other way of getting the information without using |
Hi,
I have a DSP-W115 which I would like to control without using the mydlink cloud.
I saw the comment in your readme that support of DSP-W115 might work, so I guessed I'd give it a try.
Sadly it did not work out of the box. I receive the following log/error (I added the output of the token, in order to see if it was set at all):
Do you have any hints on what to try?
Can I help you in any way?
May I ask you how you found out to control the device in this way and on what protocol that is based?
I worked with the older DLink Switches DSP-W215 with the HNAP1 interface, but sadly that does not seem to be present on the DSP-W115 anymore (or altered to a point where I can not use it, because it always rejects the login action).
//Edit:
I tried to open https://IP:8080/ in my webbrowser and it failed with the error ERR_BAD_SSL_CLIENT_AUTH_CERT if that is of any help. But that does not seem to be an issue with the python script? This is a bit over my head. 😄
//Edit2:
Ah, understood how to get more verbose logoutput. Here is with received messages:
The text was updated successfully, but these errors were encountered: