Handling HNAP - DLink DSP-W215 example

Python and python framework
tkald
Posts: 16
Joined: Friday 01 January 2016 13:38
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by tkald » Wednesday 09 August 2017 19:26

My Python skills are very limited :-) Maybe author could fix it better :-)
Dnpwwo wrote:

tkald
Posts: 16
Joined: Friday 01 January 2016 13:38
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by tkald » Thursday 10 August 2017 16:46

mozo78 wrote:
Wednesday 09 August 2017 9:56
Big THX! It is working now. :) A previous version could log the temperature and power consumption as well. Have you got a solution for these values?
Hmm, I can read a data:
Ready: {'Data': b'OK2.50', 'Status': '200', 'Headers': {'Content-Length': '474', 'Server': 'lighttpd/1.4.34', 'Content-Type': 'text/xml; charset=utf-8', 'Date': 'Thu, 10 Aug 2017 14:43:58 GMT', 'Connection': 'keep-alive'}}

Power = 2.50 W
But, I don't know, how to parse value to domoticz device :-)

Update 1:
Make backup (plugin and DB), replace plugin, sudo chmod +x plugin.py, sudo service domoticz restart, add new hardware dlink w215
power.png
power.png (18.89 KiB) Viewed 984 times
plugin.py.zip
plugin
(3.34 KiB) Downloaded 41 times
Update 2:
I can read a Temp values :-) in testing.
dlink_w215.png
w215 - switch power temp
dlink_w215.png (44.25 KiB) Viewed 971 times

User avatar
Dnpwwo
Posts: 627
Joined: Sunday 23 March 2014 10:00
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by Dnpwwo » Thursday 10 August 2017 23:50

I don'y have one of these so I can't test it but I believe this should do the trick. I used @tkald s fix and added one more.

plugin.zip
(3.23 KiB) Downloaded 64 times
backup your old plugin.py file, drop this one in the same location, go to the Hardware page, select the device and hit 'Update' to reload it
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

dennisb1
Posts: 1
Joined: Tuesday 15 August 2017 15:10
Target OS: -
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by dennisb1 » Tuesday 15 August 2017 15:12

@Tkald, With your script the two devices for on/off and power usage is created but when the connection is made Domoticz will crash.

@Dnpowwo, With your script only the on/off device is created but the same crash is happening.

What is going on? With the file from examples i dont have a crash and its sort off stable but no power usage.

User avatar
Dnpwwo
Posts: 627
Joined: Sunday 23 March 2014 10:00
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by Dnpwwo » Thursday 17 August 2017 13:47

@dennisb1,

Can you turn on debug for the plugin and post the log?
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

device33
Posts: 5
Joined: Tuesday 01 November 2016 10:20
Target OS: Linux
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by device33 » Friday 18 August 2017 21:32

Is it possible to change the socket 2 device to electric(instant+counter) to get the daily kwh usage and total kwh usage?

device33
Posts: 5
Joined: Tuesday 01 November 2016 10:20
Target OS: Linux
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by device33 » Friday 18 August 2017 21:38

I also have intermittent crashes,

heres the last lines before the crash.

Code: Select all

2017-08-18 21:33:43.841  (DSP_RIG4) Stop directive received.
2017-08-18 21:33:43.872  (DSP_RIG4) Disconnect directive received.
2017-08-18 21:33:43.872  (DSP_RIG4) Disconnect directive received.
2017-08-18 21:33:43.872  Error: Domoticz received fatal signal 6 !...
2017-08-18 21:33:43.874  Error:   /home/pi/domoticz/domoticz() [0x5d65e8]
2017-08-18 21:33:43.874  Error:   /home/pi/domoticz/domoticz(_Z14signal_handleri+0x50) [0x5d6690]
2017-08-18 21:33:43.874  Error:   /lib/x86_64-linux-gnu/libpthread.so.0(+0xf8d0) [0x7f41f90488d0]
2017-08-18 21:33:43.874  Error:   /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x7f41f832f147]
2017-08-18 21:33:43.874  Error:   /lib/x86_64-linux-gnu/libc.so.6(abort+0x148) [0x7f41f8330528]
2017-08-18 21:33:43.874  Error:   /lib/x86_64-linux-gnu/libc.so.6(+0x73294) [0x7f41f836d294]
2017-08-18 21:33:43.874  Error:   /lib/x86_64-linux-gnu/libc.so.6(+0x78a6e) [0x7f41f8372a6e]
2017-08-18 21:33:43.874  Error:   /lib/x86_64-linux-gnu/libc.so.6(+0x79776) [0x7f41f8373776]
2017-08-18 21:33:43.874  Error:   /home/pi/domoticz/domoticz(_ZN7Plugins19CPluginTransportTCP16handleDisconnectEv+0x265) [0x901d25]
2017-08-18 21:33:43.874  Error:   /home/pi/domoticz/domoticz(_ZN7Plugins13CPluginSystem7Do_WorkEv+0x37c) [0x8fb70c]
2017-08-18 21:33:43.874  Error:   /home/pi/domoticz/domoticz() [0xa1889a]
2017-08-18 21:33:43.874  Error:   /lib/x86_64-linux-gnu/libpthread.so.0(+0x80a4) [0x7f41f90410a4]
2017-08-18 21:33:43.874  Error:   /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f41f83e29cd]
I think it's related to when the DSP is offline and i try to make changes at the hardware tab in domoticz.

tkald
Posts: 16
Joined: Friday 01 January 2016 13:38
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by tkald » Friday 25 August 2017 16:01

Small preview with temp and kWh, still testing :-)
IMG_0014.PNG
IMG_0014.PNG (103.87 KiB) Viewed 813 times
For kWh I used a custom sensor, I dont know how exactly used a defined 'kWh' device :-)

RvD
Posts: 8
Joined: Wednesday 15 October 2014 18:54
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by RvD » Monday 28 August 2017 19:36

Hello,

I also have two of these devices and would like to include them in Domoticz, so I'd like to thank you all for your hard work and I hope there'll be a stable version soon!

transistorGL
Posts: 1
Joined: Tuesday 19 September 2017 22:46
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by transistorGL » Tuesday 19 September 2017 23:09

hello everybody
I'm new to Domoticz....I just started tonight... and I have one of these dlink home plug
Where can I find a document on hot to setparameters inside domoticz and get the last working version of plugin.py
I can see the device in my list.. but I can't turn iton and off...
Do I have to be in the same lan ?
thanks for your help and sorry for my dummy question

device33
Posts: 5
Joined: Tuesday 01 November 2016 10:20
Target OS: Linux
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by device33 » Monday 30 October 2017 13:11

Would you mind sharing the kWh script?

vizion88
Posts: 6
Joined: Sunday 12 March 2017 14:01
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by vizion88 » Saturday 04 November 2017 22:55

Hi all,

Bought myself such a DSP-W215 and hooked it up in my WiFi. Now I copied the examplecode from the examples folder to the plugins directory. Tried to find my DSP-W215 in the hardware list but nothing there. What am I missing out here? I'm running the stable release version 3.8153

Thanks!


I got it working now, for future reference my actions:
  • Get your DSP-W215 set up in your local network
  • Create a directory with name DSP-W215 in /home/pi/domoticz/plugins/ with permissions set to 775 (chmod 775 DSP-W215)
  • Copy the example from /home/pi/domoticz/plugins/examples/Dlink DSP-W215.py to your newly created folder with name plugin.py
  • Restart domoticz service with sudo service domoticz.sh restart
  • Find the device in your hardware list
Hope it helps!

tkald
Posts: 16
Joined: Friday 01 January 2016 13:38
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by tkald » Sunday 05 November 2017 8:25

vizion88 wrote:
Saturday 04 November 2017 23:35
Did you finish the script including kWh already? Would be so nice to have it!

All the best,
Ben
device33 wrote:
Monday 30 October 2017 13:11
Would you mind sharing the kWh script?
Script:
plugin.py.zip
(3.52 KiB) Downloaded 35 times

vizion88
Posts: 6
Joined: Sunday 12 March 2017 14:01
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by vizion88 » Sunday 05 November 2017 20:45

tkald wrote:
Sunday 05 November 2017 8:25

Script: plugin.py.zip
No success, domoticz crashes when I use your Plugin.py. I've attached the logfile :)
Attachments
log.txt
(11.65 KiB) Downloaded 16 times

tkald
Posts: 16
Joined: Friday 01 January 2016 13:38
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by tkald » Sunday 05 November 2017 22:54

vizion88 wrote:
Sunday 05 November 2017 20:45
tkald wrote:
Sunday 05 November 2017 8:25

Script: plugin.py.zip
No success, domoticz crashes when I use your Plugin.py. I've attached the logfile :)
Sorry, i cant help with this. I tested a plugin with fresh beta release on rpi and works fine. Try complete reboot.

art4me
Posts: 1
Joined: Tuesday 12 December 2017 11:27
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Handling HNAP - DLink DSP-W215 example

Post by art4me » Tuesday 12 December 2017 11:34

Hello, I'm trying to install the plugin but something very strange is happening.

My Domoticz version is 3.8775 (beta release). I install the plugin inside domoticz/plugins/DSP-W215 and set file permission to 775.
then I restart domoticz service, I open Hardware page and add the hardware from the list (it appears correctly). Then I go to Devices and Domoticz crashes (Offline). To fix the problem I need to move the plugin out from the plugins folder, else Domoticz remains offline.

The log error gives me this:

Code: Select all

2017-12-08 13:07:00.124 Error: (DSP-W215) failed to load 'plugin.py', Python Path used was ':/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2017-12-08 13:07:00.124 Error: (Dlink) Module Import failed, exception: 'ImportError'
2017-12-08 13:07:00.124 Error: (Dlink) Module Import failed: ' Name: plugin'
2017-12-08 13:07:00.125 Error: (Dlink) Error Line details not available.
2017-12-08 13:08:00.785 Error: Dlink hardware (12) thread seems to have ended unexpectedly
I tried to see if it was a Python version that needs to be update but it's the last version.
Suggestions?

UPDATE
I found out that HNAP1 protocol has problems (that's why the Error: Module Import failed.
I tried to access to the XML file on my smart plug (http://smartplugip/HNAP1/) but it looks empty.
So I tried to understand where the problem could be and found out that the SOAP Action link is broken: http://purenetworks.com/HNAP1/

Somebody can help me in this? Maybe D-Link decided not to provide this protocol anymore? I read that it has many bad comment because of vulnerability.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests