UpDryTwist / dlink-dchs150-hass

Home Assistant custom component to support the mostly-defunct D-Link DCH-S150 motion detector
MIT License
7 stars 0 forks source link
d-link dch-s150 home-assistant homeassistant

dlink_dchs150_hass

GitHub Release GitHub Activity License

pre-commit Black

hacs Project Maintenance BuyMeCoffee

Discord Community Forum

This component will set up the following platforms.

Platform Description
binary_sensor Show something True or False.

This is a Home Assistant driver for the D-Link DCH-S150 motion detector, which is no longer supported by D-Link. This component does what it can to smack the device into shape -- including the ability to set the backoff time (how long it ignores additional motion detections), the ability to set the Home Assistant polling time (upgrade from prior components), the ability to fix the time zone settings (important now that D-Link's URLs are no longer any good), the ability to tweak sensitivity, and various other improvements.

DCH-S150

Installation

  1. Using the tool of choice open the directory (folder) for your HA configuration (where you find configuration.yaml).
  2. If you do not have a custom_components directory (folder) there, you need to create it.
  3. In the custom_components directory (folder) create a new folder called dchs150_motion.
  4. Download all the files from the custom_components/dchs150_motion/ directory (folder) in this repository.
  5. Place the files you downloaded in the new directory (folder) you created.
  6. Restart Home Assistant
  7. In the HA UI go to "Configuration" -> "Integrations" click "+" and search for "DLink"

Using your HA configuration directory (folder) as a starting point you should now also have this:

custom_components/dchs150_motion/translations/en.json
custom_components/dchs150_motion/translations/fr.json
custom_components/dchs150_motion/translations/nb.json
custom_components/dchs150_motion/__init__.py
custom_components/dchs150_motion/api.py
custom_components/dchs150_motion/binary_sensor.py
custom_components/dchs150_motion/config_flow.py
custom_components/dchs150_motion/const.py
custom_components/dchs150_motion/dch_wifi.py
custom_components/dchs150_motion/entity.py
custom_components/dchs150_motion/hass_integration.py
custom_components/dchs150_motion/manifest.json
custom_components/dchs150_motion/strings.json

Configuration is done in the UI

You can do a lot of additional configuration by clicking "Configuration" in the device setup. Some of this is even more than you could do in the initial phone app!

NOTE: Pushing these parameters has only been tested a bit on my devices -- no guarantees it won't screw up your device somehow. But given that these devices are close to dead, anyhow, why not experiment!

Here are some parameters you can tinker with:

Parameter Description
Update Interval Sets the polling frequency from HASS. You can set this to any number; it's in seconds (fractional seconds appear to work). Note that the smaller the number, the more network traffic, and the more server load -- but the faster the responsiveness.
Device Wait Otherwise known as "backoff". This is how long the device ignores additional motion, before detecting a "new" motion. By default, this was set to 30 seconds in the device - you probably noticed that it would ignore your motion. If you're trying to get a motion sensor that keeps triggered when you keep moving (this is, I think, the normal case), then set this down low, like 1-2 seconds. Just the ability to bump this down made the device so much better for me!
Sensitivity I'm not sure exactly how this works, but you can tweak it to see how it goes . . .
Disable Detector It's a setting, so I included it . . . but why bother?
Nickname I don't know that this is useful, but it can be set. NOTE: I couldn't get the HNAP command SetDeviceSettings to work, so I couldn't reset the basic device name, which is what would be really useful. If you know the parameters to that command, please let me know!
Description Another one that may not be useful . . . but you can set it on the device . . .
NTP server The device really needs to get to a good NTP server, or it won't work. By default it goes to ntp1.dlink.com. That DNS entry was offline for a while, but recently (2023-03-30) has been repointed to time2.google.com. I default this to time.google.com.
Time zone stuff You should set this all appropriately for your location.

Initializing a device

If for some reason you have a DCH-S150 that you never configured, or if you have to factory-reset your device (hopefully not because you were futzing with parameters with this component!), then you can check out my script here

Contributions are welcome!

If you want to contribute to this please read the Contribution guidelines

Credits

This project was generated from @oncleben31's Home Assistant Custom Component Cookiecutter template.

Code template was mainly taken from @Ludeeus's integration_blueprint template

Couldn't say enough good things about @postlund's original D-Link HNAP integration, which formed the initial base for the HNAP communications!

Some additional work added from @openhab's D-Link implementation

Double-checked against @iobroker-community-adapters D-Link implementation

You can find HNAP documentation (a bit old) here, which was useful for probing the device.

For deconstructing what might be happening in the firmware, take a look at @0xdead8ead's copy of the DIR-865 firmware or @jhbsz's copy of the DIR-850L_A1 firmware -- this was helpful in guessing parameters in general for the D-Link HNAP implementation.

In terms of understanding the authentication handshake, check out the Embedded Lab Vienna for IoT & Security (ELVIS)'s HNAPown for a good discussion of brute forcing the embedded HTTP server.