Handling HNAP - DLink DSP-W215 example

Python and python framework

Moderator: leecollings

User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Handling HNAP - DLink DSP-W215 example

Post by Dnpwwo »

Sample shows connecting (& reconnecting) over HTTP using SOAP.

Despite supporting HTTP 1.1 the DSP-W215 will disconnect after 10 seconds so a heartbeat query status happens every 8 seconds to prevent it. It will disconnect after 2 minutes anyway (Why DLink? Why!) so the disconnect initiates an immediate reconnect.

This should allow control of the remote device from within Domoticz and reflect direct changes on the device back into Domoticz.
DLink DSP-W215 v1.0.0.rar
(2.97 KiB) Downloaded 577 times
Requires the latest beta otherwise Domoticz will crash if the plugin is updated in the Hardware page.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
korniza
Posts: 157
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6028
Location: Greece
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by korniza »

@Dnpwwo you are super! :D
I just installed! The response is VERY FAST when switch on/off. The problem is that even I have latest beta version (3.6518), I got domoticz crashing.
I enabled debug and I found this:
11:18:49.459 Error: Plugin: Async Read Exception: 125, Operation canceled
I like to thank Dnpwwo! Can we also add the power usage and temperature for this plug? :D
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
saiko
Posts: 7
Joined: Monday 30 January 2017 15:32
Target OS: -
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by saiko »

Hi guys,

I just bought the DSP-W215.
Firmware External Version: V2.02
Firmware Internal Version: V2.02b04
Date: Wed, 22 Oct 2014

And I'd love to test this out.

However I'm unable to install the script in Domoticz. I've installed the script at: /home/pi/domoticz/plugin/DSP-W215/plugin.py and gave it 0744 permissions. After the reboot it doesnt show up under hardware dropdown list. What am I doing wrong?

Regards,
Saiko
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by Dnpwwo »

@saiko,

It needs to be : /home/pi/domoticz/plugins/DSP-W215/plugin.py

This will only work on the beta channel of Domoticz which you may not be running if the plugins folder wasn't there
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
saiko
Posts: 7
Joined: Monday 30 January 2017 15:32
Target OS: -
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by saiko »

Dnpwwo wrote:@saiko,

It needs to be : /home/pi/domoticz/plugins/DSP-W215/plugin.py

This will only work on the beta channel of Domoticz which you may not be running if the plugins folder wasn't there
I've renamed the plugin map to plugins and rebooted Domoticz. However I'm unable to find d-link or DSP-w215 under hardware.

I'm running beta v3.6562 by changing Software Updates: to beta channel and updating. This however did not create the plugins folder.

Any suggestions?
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by Dnpwwo »

@korniza,

Can you try this one:
DLink DSP-W215 v1.1.0.rar
(3.27 KiB) Downloaded 368 times
You will need to:
  • Replace the plugin.py file with the one in the archive
  • In Domoticz, delete the switch associated with the plugin from the devices page
  • Restart Domoticz and there should be switch, temperature and usage devices for the DLink
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
korniza
Posts: 157
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6028
Location: Greece
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by korniza »

it worked everything 100%! :D
I'm a happy owner of DSP-W215 as they are an alternative solution from zwave to control plugs and get power usage! amazing!
As a learner I tried also to do it by myself using your code but I failed to pass value on domoticz, so now I can find my errors and check if I can do something with less or no help and share it back (I m a dreamer...) :lol:
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
benboyte
Posts: 5
Joined: Wednesday 01 February 2017 22:15
Target OS: -
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by benboyte »

Hi,

I installed Domoticz (stable version) yesterday.
I created the "plugins" directory (744 permissions) and installed the script (v.1.1.0) in : /home/pi/domoticz/plugins/DSP-W215/plugin.py

I just upgraded Domoticz to the beta version (3.6577) but DSP-W215 does not appear in the Hardware page.

What can I do to make it works?

Thanks a lot for this plugin.
korniza
Posts: 157
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6028
Location: Greece
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by korniza »

benboyte wrote:Hi,

I installed Domoticz (stable version) yesterday.
I created the "plugins" directory (744 permissions) and installed the script (v.1.1.0) in : /home/pi/domoticz/plugins/DSP-W215/plugin.py

I just upgraded Domoticz to the beta version (3.6577) but DSP-W215 does not appear in the Hardware page.

What can I do to make it works?

Thanks a lot for this plugin.
Did you restart domoticz service?
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
benboyte
Posts: 5
Joined: Wednesday 01 February 2017 22:15
Target OS: -
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by benboyte »

korniza wrote:
benboyte wrote:Hi,

I installed Domoticz (stable version) yesterday.
I created the "plugins" directory (744 permissions) and installed the script (v.1.1.0) in : /home/pi/domoticz/plugins/DSP-W215/plugin.py

I just upgraded Domoticz to the beta version (3.6577) but DSP-W215 does not appear in the Hardware page.

What can I do to make it works?

Thanks a lot for this plugin.
Did you restart domoticz service?
Yes I did, more than once.

I reinstalled the stable version, deleted the plugins directory (created manually previously), and updated to beta...the plugins directory is not created automatically...is it normal ?
korniza
Posts: 157
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6028
Location: Greece
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by korniza »

benboyte wrote:
korniza wrote:
benboyte wrote:Hi,

I installed Domoticz (stable version) yesterday.
I created the "plugins" directory (744 permissions) and installed the script (v.1.1.0) in : /home/pi/domoticz/plugins/DSP-W215/plugin.py

I just upgraded Domoticz to the beta version (3.6577) but DSP-W215 does not appear in the Hardware page.

What can I do to make it works?

Thanks a lot for this plugin.
Did you restart domoticz service?
Yes I did, more than once.

I reinstalled the stable version, deleted the plugins directory (created manually previously), and updated to beta...the plugins directory is not created automatically...is it normal ?
I am not sure as you had upgrade from stable to beta what can cause this issue. :roll:
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)
saiko
Posts: 7
Joined: Monday 30 January 2017 15:32
Target OS: -
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by saiko »

benboyte wrote:Hi,


Yes I did, more than once.

I reinstalled the stable version, deleted the plugins directory (created manually previously), and updated to beta...the plugins directory is not created automatically...is it normal ?
I'm having the same issue. I guess we have to wait untill this is added in the stable release.
dezde29
Posts: 9
Joined: Saturday 04 February 2017 22:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by dezde29 »

Hi,

I had the same problem but since I apply :

sudo apt-get install libpython3.4

From : http://www.domoticz.com/wiki/Linux#Prob ... ing_Python

Restart domoticz and Dlink has appear in the hardware list.

Hope it helps.
saiko
Posts: 7
Joined: Monday 30 January 2017 15:32
Target OS: -
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by saiko »

dezde29 wrote:Hi,

I had the same problem but since I apply :

sudo apt-get install libpython3.4

From : http://www.domoticz.com/wiki/Linux#Prob ... ing_Python

Restart domoticz and Dlink has appear in the hardware list.

Hope it helps.
Yes this did the trick thank you!
jelleeelco
Posts: 61
Joined: Wednesday 04 January 2017 15:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by jelleeelco »

Wow, this is great!

Just a quick question before I change my setup... I currently use Korniza code to switch them, just by IP address. So Domoticz doesn't really knows the status, temp or usage. This looks great, but... I have three Dlink plugs. Will three of them show up or will it only work on one?

Do I need to set an IP address in the file?

Thanks!
Jelle
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by Dnpwwo »

@jelleeelco,

Do not set the IP in the file, if you are running a recent beta and Domoticz is finding Python on your system (there will be a message in the log at startup either way) then you can find this in the list of supported hardware in the Hardware page and you can configure 4 instances of it there.

You need to drop the file plugin.py into a folder under domoticz/plugins e.g domoticz/plugins/DLink
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
jelleeelco
Posts: 61
Joined: Wednesday 04 January 2017 15:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by jelleeelco »

Thanks!!

I setup it up and it finds the Plug. I entered the the MyDlink number as the username and the pin as the password. It then finds the thermometer, the switch and the usage meter.

however, I can't switch it off/on with the switch. When press the switch, the log states the following:

User: Admin initiated a switch command (80/Dlink Plug 1 - Socket/off

No error message at that time.

However, it does correctly show the temperature and the status (if I switch off manually on the plug, the switch in Domoticz changes status).
Also it doesn't seem to matter what username I use... When I used the MyDlink number it worked (apart from switching) and now I readded everything with username Admin, and the same...

EDIT: Forgot that my first plug had a lot of Firmware updates... I'll add this one to the MyDlink app first and then try again.
benboyte
Posts: 5
Joined: Wednesday 01 February 2017 22:15
Target OS: -
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by benboyte »

dezde29 wrote:Hi,

I had the same problem but since I apply :

sudo apt-get install libpython3.4

From : http://www.domoticz.com/wiki/Linux#Prob ... ing_Python

Restart domoticz and Dlink has appear in the hardware list.

Hope it helps.
Thanks a lot, it worked for me.
dramich
Posts: 2
Joined: Saturday 11 March 2017 10:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by dramich »

Hi after upgrade to V3.6914
I have errors (maybe not errors but switch dont work) with my dsp-w215 switch:

(PIEC_OBIEG_WODY) Initialized version 1.1.0, author 'Dnpwwo'
2017-03-11 10:36:22.084 (PIEC_OBIEG_WODY) Devices created.
2017-03-11 10:36:22.085 PluginSystem: Starting I/O service thread.
2017-03-11 10:36:52.786 PluginSystem: Restarting I/O service thread.
2017-03-11 10:36:52.787 (PIEC_OBIEG_WODY) Device has disconnected
2017-03-11 10:36:52.787 PluginSystem: Starting I/O service thread.

Can You help me?

After enable debug mode got
2017-03-11 15:32:32.104 (PIEC_OBIEG_WODY) 48 54 54 50 2f 31 2e 31 20 35 30 30 20 49 6e 74 65 72 6e 61 HTTP/1.1.500.Interna
2017-03-11 15:32:32.105 (PIEC_OBIEG_WODY) 6c 20 53 65 72 76 65 72 20 45 72 72 6f 72 0d 0a 43 6f 6e 74 l.Server.Error..Cont
2017-03-11 15:32:32.105 (PIEC_OBIEG_WODY) 65 6e 74 2d 54 79 70 65 3a 20 74 65 78 74 2f 68 74 6d 6c 0d ent-Type:.text/html.
2017-03-11 15:32:32.105 (PIEC_OBIEG_WODY) 0a 43 6f 6e 74 65 6e 74 2d 4c 65 6e 67 74 68 3a 20 33 36 39 .Content-Length:.369
2017-03-11 15:32:32.105 (PIEC_OBIEG_WODY) 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 6b 65 65 70 2d 61 ..Connection:.keep-a
2017-03-11 15:32:32.105 (PIEC_OBIEG_WODY) 6c 69 76 65 0d 0a 44 61 74 65 3a 20 53 61 74 2c 20 31 31 20 live..Date:.Sat,.11.
2017-03-11 15:32:32.105 (PIEC_OBIEG_WODY) 4d 61 72 20 32 30 31 37 20 31 34 3a 33 32 3a 33 31 20 47 4d Mar.2017.14:32:31.GM
2017-03-11 15:32:32.105 (PIEC_OBIEG_WODY) 54 0d 0a 53 65 72 76 65 72 3a 20 6c 69 67 68 74 74 70 64 2f T..Server:.lighttpd/
2017-03-11 15:32:32.105 (PIEC_OBIEG_WODY) 31 2e 34 2e 33 34 0d 0a 0d 0a 3c 3f 78 6d 6c 20 76 65 72 73 1.4.34....
2017-03-11 15:32:32.105 (PIEC_OBIEG_WODY) 69 6f 6e 3d 22 31 2e 30 22 20 65 6e 63 6f 64 69 6e 67 3d 22 ion="1.0".encoding="
2017-03-11 15:32:32.106 (PIEC_OBIEG_WODY) 69 73 6f 2d 38 38 35 39 2d 31 22 3f 3e 0a 3c 21 44 4f 43 54 iso-8859-1"?>.
2017-03-11 15:32:32.106 (PIEC_OBIEG_WODY) 59 50 45 20 68 74 6d 6c 20 50 55 42 4c 49 43 20 22 2d 2f 2f YPE.html.PUBLIC."-//
2017-03-11 15:32:32.106 (PIEC_OBIEG_WODY) 57 33 43 2f 2f 44 54 44 20 58 48 54 4d 4c 20 31 2e 30 20 54 W3C//DTD.XHTML.1.0.T
2017-03-11 15:32:32.106 (PIEC_OBIEG_WODY) 72 61 6e 73 69 74 69 6f 6e 61 6c 2f 2f 45 4e 22 0a 20 20 20 ransitional//EN"....
2017-03-11 15:32:32.106 (PIEC_OBIEG_WODY) 20 20 20 20 20 20 22 68 74 74 70 3a 2f 2f 77 77 77 2e 77 33 ......"http://www.w3
2017-03-11 15:32:32.106 (PIEC_OBIEG_WODY) 2e 6f 72 67 2f 54 52 2f 78 68 74 6d 6c 31 2f 44 54 44 2f 78 .org/TR/xhtml1/DTD/x
2017-03-11 15:32:32.106 (PIEC_OBIEG_WODY) 68 74 6d 6c 31 2d 74 72 61 6e 73 69 74 69 6f 6e 61 6c 2e 64 html1-transitional.d
2017-03-11 15:32:32.106 (PIEC_OBIEG_WODY) 74 64 22 3e 0a 3c 68 74 6d 6c 20 78 6d 6c 6e 73 3d 22 68 74 td">.
2017-03-11 15:32:32.106 (PIEC_OBIEG_WODY) 74 70 3a 2f 2f 77 77 77 2e 77 33 2e 6f 72 67 2f 31 39 39 39 tp://www.w3.org/1999
2017-03-11 15:32:32.107 (PIEC_OBIEG_WODY) 2f 78 68 74 6d 6c 22 20 78 6d 6c 3a 6c 61 6e 67 3d 22 65 6e /xhtml".xml:lang="en
2017-03-11 15:32:32.107 (PIEC_OBIEG_WODY) 22 20 6c 61 6e 67 3d 22 65 6e 22 3e 0a 20 3c 68 65 61 64 3e ".lang="en">..
2017-03-11 15:32:32.107 (PIEC_OBIEG_WODY) 0a 20 20 3c 74 69 74 6c 65 3e 35 30 30 20 2d 20 49 6e 74 65 ...
2017-03-11 15:32:32.107 (PIEC_OBIEG_WODY) 72 6e 61 6c 20 53 65 72 76 65 72 20 45 72 72 6f 72 3c 2f 74 rnal.Server.Error
2017-03-11 15:32:32.107 (PIEC_OBIEG_WODY) 69 74 6c 65 3e 0a 20 3c 2f 68 65 61 64 3e 0a 20 3c 62 6f 64 itle>....
2017-03-11 15:32:32.107 (PIEC_OBIEG_WODY) 79 3e 0a 20 20 3c 68 31 3e 35 30 30 20 2d 20 49 6e 74 65 72 y>...
500.-.Inter
2017-03-11 15:32:32.107 (PIEC_OBIEG_WODY) 6e 61 6c 20 53 65 72 76 65 72 20 45 72 72 6f 72 3c 2f 68 31 nal.Server.Error
2017-03-11 15:32:32.107 (PIEC_OBIEG_WODY) 3e 0a 20 3c 2f 62 6f 64 79 3e 0a 3c 2f 68 74 6d 6c 3e 0a .. >....
User avatar
Dnpwwo
Posts: 819
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by Dnpwwo »

@dramich,

I did a big upgrade to the framework a week ago and broke some of the HTML functionality. I have pushed a fix today (request #1336) that should sort things out when it is merged hopefully later today.

Can you try that a report back if you still have issues.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest