D-Link Motion Sensor DCH-S150

Been using the Custom Component for some time without issue, must moved over to HACS compatible one, no issues, works great. Thanks.

1 Like

Thanks everyone for testing! The repository has just been added to HACS, so it will be available without having to add it as a custom repository within the next few hours.

1 Like

Thank you very much for hacs integration! Working great!

1 Like

Working all good for me.
However old link is not available and new link is here:

I’ve also forked for failsafe here:

That’s the old repo, you should use the dlink_hnap repo. Or install via HACS.

I’m new to HASS so forgive me if this is a newbie question.

After a bit of pain, I got this old DCH-S150 connected to my network. Via HACS I installed dlink_hnap and then manually configured the configuration.yaml file. In HASS, the device shows up as Hall Motion with Entity ID binary_sensor.hall_motion. It seems to be working okay because I can see the activity.

My issue comes when I try and use it for some automation. As I understand it, there isn’t a GUI so I need to edit as YAML. My trigger looks like this:

platform: dlink_hnap
type: motion
domain: switch
entity_id: binary_sensor.hall_motion

But I get an error Message malformed: Integration ‘dlink_hnap’ does not provide trigger support

How can I use this as a trigger? Advice appreciated!

This is my configuration.yaml entry:

binary_sensor:

  • platform: dlink_hnap
    name: dlink sensor
    host: 192.168.1.200
    type: motion
    username: Admin
    password: ******
    timeout: 35

This is my automation trigger:

  • id: ‘1547840481258’
    alias: Hallway Light On if Motion
    trigger:
    • entity_id: binary_sensor.dlink_sensor
      from: ‘off’
      platform: state
      to: ‘on’

Thanks Gary. How do I establish the ID?

Ignore that. I think I’ve worked it out.

In Developer Tools > Events > Event to subscribe to I choose * then start listening then trigger the sensor. That gives me some information.

The ID in the Automation is created by the Automation editor in Configuration/Automations. You can use the Automation editor to create Automations for this device once it has an entity, and the configuration.yaml entries create the entity.

1 Like

Thanks. The automation worked for a few days but now it seems something has gone wrong with the integration. As best I remember, the device used to show on/off state but now it just shows ‘clear’.

The IP address hasn’t changed and the sensor still seems to be working, judging by the LED light. Any ideas?

You need to check the logs for additional pointers.

Thank you, Pierre. That hadn’t occurred to me.

2020-11-03 21:41:17 ERROR (MainThread) [custom_components.dlink_hnap.binary_sensor] failed to update motion sensor
Traceback (most recent call last):
  File "/config/custom_components/dlink_hnap/binary_sensor.py", line 113, in async_update
    last_trigger = await self._sensor.latest_trigger()
  File "/config/custom_components/dlink_hnap/dlink.py", line 174, in latest_trigger
    detect_time = resp["LatestDetectTime"]
KeyError: 'LatestDetectTime'

I see that error repeated over and over. Seems to be having a problem getting LatestDetectTime from the device.

EDIT: Seems to be working again now.

I am getting this error when I install this via HACS

This error originated from a custom integration.

Logger: custom_components.dlink_hnap.binary_sensor
Source: custom_components/dlink_hnap/dlink.py:193
Integration: dlink_hnap (documentation, issues)
First occurred: 1:09:24 PM (2118 occurrences)
Last logged: 4:06:11 PM

failed to update motion sensor
Traceback (most recent call last):
  File "/config/custom_components/dlink_hnap/binary_sensor.py", line 113, in async_update
    last_trigger = await self._sensor.latest_trigger()
  File "/config/custom_components/dlink_hnap/dlink.py", line 169, in latest_trigger
    await self._cache_soap_actions()
  File "/config/custom_components/dlink_hnap/dlink.py", line 193, in _cache_soap_actions
    self._soap_actions = resp["ModuleSOAPList"]["SOAPActions"]["Action"]
KeyError: 'ModuleSOAPList'

With great sadness this device is as good as junk now. Support has ended and the dlink myhome app which you use to pair these things cant be downloaded anymore from the app store

That’s not enterely true. D-link has shut down the server part of this device but the app is still available on the Play Store. The problem is that not even older versions of this app can configure the device, I guess the app fetches from the web a list of configurable devices and the DCH-S150 is not one of them anymore.
If I’ve read things right, this integrations allow us to directly fetch data from the API endpoint of the device itself, right?
If we can figure out how the app configures the WiFI connection of the device and we can do it ourselves we could avoid to trash a perfectly fine device because someone decides to shut down their servers


Sure I guess “anything” is possible

To clarify:

  • Apple App Store app is gone
  • The devices are trying to hit an API that no longer exists (I noticed 157k dns requests on my adguard in just under a week)

Just adding to this, I’m also annoyed that D-Link did not at least give a method that these could still be used and configured off the cloud. I have a few unfortunately they were configured using the iOS App which I still have on my iPhone, but I can no longer login to the App, I actually had a few D-Link devices, 2 WebCams, 5 x Water sensors.

I cannot access any of them, because I do not know the password, I’ve never configured a password, as they were only used by the MyDlink website and app. They are all currently enabled and connected to my WiFi, fear of hardware reset will just scrap them, as no method to configure, I believe originally, there was a QR code which I scanned, which configured and added them to the Cloud, there’s some mention of a PIN number on the device to login, but I see no pin number.

if you know the password, does this HA “plugin” operate correctly ?

Y’all are in luck! I have a bunch of DCH-S150 motion detectors sitting around, as well as a couple still that I bought cheap and never activated before the D-Link cloud/app went away. So I got motivated to figure out how to activate them. Not easy, as there’s just not much information on the HNAP protocol, and in particular, how D-Link devices implement it.

Cutting to the chase, here’s a Python script that you can use to set the wi-fi access on your device (anyhow, it worked for me): https://raw.githubusercontent.com/UpDryTwist/defogger-dch-s150/master/dch-wifi.py

You can also use this code as a basis to tinker with further, in terms of other HNAP commands (if anyone finds a way to set the detection reset time down shorter than 30 seconds, you’ll be my hero!).

Some comments:

  • You can probably ignore the rest of the project it’s in. I initially cloned bmork’s cool DCS-8000LH defogger (i.e., cloud remover) project, and started tinkering with that, until I remembered that I’d never been successful setting up my devices using Bluetooth from my phone – so I never got the BTLE stuff to work – and, frankly, you don’t need to.

  • You need to connect to the access point the device advertises. Afterwards, it’ll probably show up at IP 192.168.0.60. Make sure you can access that cleanly before anything else (you can go try logging in at that IP - won’t accomplish much, but proves you can get there).

  • In theory, this code supports both password-protected wi-fi and open wi-fi. I wrote all the code to work with a password, and debugged it through to the point that the D-Link device was accepting my requests without error, but not connecting to my network . . . and then I finally remembered that I had to set up a whole separate 2.4Ghz open network (filtered by MAC address) for these devices, as they didn’t like connecting to my main network. SO . . . if your network is password protected, this may or may not work for you.

  • Super props to Pierre StĂ„hl (postlund), whose copied code (from his Home Assistant driver) made the whole basis for my D-Link communications.

  • I just got this to work this evening, so haven’t cleaned anything up. Unfortunately, I’ve exhausted my tinkering-with-this budget, so can’t provide folks much in the way of support or documentation - but hopefully it’s easy-enough to work with or extend.

1 Like

is it still working for you all?