D-Link Motion Sensor DCH-S150

Worked for me too. Many thanks.

Has anyone else had a problem with 0.92.2?

For my checklist:

  • I retrieved the binary_sensor.py and dlink.py from the Feb 23 post by @postlund.
  • I placed both in \home\homeassistant\.homeassistant\custom_components\dlink_motion_sensor.
  • I added an empty file named __init__.py in the dlink_motion_sensor folder.
  • I have this in my config:
# Binary Sensors
binary_sensor:
  # Ring
  - platform: ring
  # D-Link Motion Sensor
  - platform: dlink_motion_sensor
    name: Motion Sensor
    host: !secret motion_sensor_host
    password: !secret motion_sensor_password
  # Ping
  - platform: ping
    host: !secret ping_host
    count: 2
    scan_interval: 5

When I comment out or remove the motion sensor in the config, everything is fine. When I add it back I receive 500 Internal Server Error Server got itself in trouble. My guess is that thereā€™s an issue with the component; since the config worked before. Do I need some sort of boilerplate in the __init__.py?

Where do you see the internal server error? You should have a stacktrace somewhere, wonā€™t be possible to debug without it.

Mon May 06 2019 11:27:29 GMT-0600 (Mountain Daylight Time)
Error handling request
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/real_ip.py", line 33, in real_ip_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/ban.py", line 68, in ban_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/auth.py", line 216, in auth_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/view.py", line 115, in handle
    result = await result
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/config/core.py", line 21, in post
    errors = await async_check_ha_config_file(request.app['hass'])
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/config.py", line 824, in async_check_ha_config_file
    res = await check_ha_config_file(hass)  # type: ignore
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/scripts/check_config.py", line 389, in check_ha_config_file
    platform = p_integration.get_platform(domain)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/loader.py", line 139, in get_platform
    "{}.{}".format(self.pkg_path, platform_name)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 669, in exec_module
  File "<frozen importlib._bootstrap_external>", line 775, in get_code
  File "<frozen importlib._bootstrap_external>", line 735, in source_to_code
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/homeassistant/.homeassistant/custom_components/dlink_motion_sensor/binary_sensor.py", line 7
    <!DOCTYPE html>
    ^
SyntaxError: invalid syntax

Here we go. I thought for a moment after looking at this that maybe the detectorā€™s IP address had changed. But no, it is still the same.

OMG! never mindā€¦
Dang!
I use the save link as in github. Of course that saved the whole html page not just the fileā€¦ sorry /facepalm

Yeah, you did :wink:

Hi there, just a quick message to convey my thanks. Iā€™ve been using home assistant as an end user for about a year now, but I havenā€™t got much programming skills, so this is just my way of contributing I guess. Your custom integration for the motion sensor works very well and was very usefull in my home situation!
Just summarizing for other people who would be interested: Put the two files from github in the config folder under ā€œcustom_components/dlink_motion_sensorā€. Then add an empty file called "__init__.py" to the same folder, otherwise it wonā€™t work. Then reboot HA. Lastly, add this to the configuration.yaml:

binary_sensor:

  • platform: dlink_motion_sensor
    name: Some sensor
    host: dlink_motion_sensor_ip_address
    password: !secret motion_sensor_password

The password should be the pin code that comes with the sensor.

1 Like

If you use Hassio reboot system, not only HA. (menu: Hassio -> System -> Reboot). Iā€™ve spent hours to solve this issue :).

Not working on 94.4 for anyone else?

It works in 0.94.4 as before.

1 Like

Nevermind got it working. Just needed a power cycle

Iā€™m now finding that after every HA restart or update i need to power cycle the motion sensor for it to work again

Iā€™m still stuck at this error. On 0.95 here.
ā€œIntegration dlink_motion_sensor not found when trying to verify its binary_sensor platform.ā€

Thank you for the summary, this was really helpful. However I have one question, is there a way of retrieving the pin code if you cannot remember it? :slight_smile: I do have the sensor setup in the dlink app and IFTTT if that helps me?

Itā€™s on the back of the sensor. At least on the two units I have.

1 Like

Thank you very much, the plug did have the pin!

Hi,

I noticed today at 12:03 pm a sensor triggered and 12:09 pm another sensor triggered in home assistant, as we arenā€™t home right now I thought thatā€™s strange but then I checked the Dlink app for both of these sensors and it shows these times but they show up as yesterday the 20th and none triggered today. Strange as these 2 sensors only triggered once today at these 2 times. Bit of a coincidence.

Could this be a bug in the code? At first I thought maybe I was reading the home assistant log incorrectly but I was not mistaken.

Does anyone know if this has happened to them, I wonder if it has something to do with it being just after 12.

is anybody still using this with Home Assistant 0.105.3?
I pulled down the 3 files from GitHub, tried different folders but then gives me error after the add to the configuration.yaml

in which path you guys have the 3 files? is it still compatible with 0.105.3?
thanks

I use it and it works.

where did you put the 3 file .py?