D-Link Motion Sensor DCH-S150


#64

The most recent code in warner’s repo works, but I ended up replacing the S150’s with a zigbee based device that has proven a lot more reliable.

The DLink seems to update its firmware automatically, fairly frequently, and each time breaks connectivity.


#65

Im trying to set one of these up in an HASS.io installation i did today. I’m using the files from warners repo but I am getting errors and am not sure how to proceed.

Here are what I think are the related errors Testing configuration at /config ERROR:homeassistant.scripts.check_config:BURB Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 207, in check res['components'] = check_ha_config_file(hass) File "/usr/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 372, in check_ha_config_file platform = loader.get_platform(hass, domain, p_name) File "/usr/lib/python3.6/site-packages/homeassistant/loader.py", line 58, in get_platform return get_component(hass, PLATFORM_FORMAT.format(domain, platform)) File "/usr/lib/python3.6/site-packages/homeassistant/loader.py", line 86, in get_component module = importlib.import_module(path) File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 674, in exec_module File "<frozen importlib._bootstrap_external>", line 781, in get_code File "<frozen importlib._bootstrap_external>", line 741, in source_to_code File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/config/custom_components/binary_sensor/dlink_motion_sensor.py", line 7 <!DOCTYPE html> ^ SyntaxError: invalid syntax Fatal error while loading config: invalid syntax (dlink_motion_sensor.py, line 7) Failed config General Errors: - invalid syntax (dlink_motion_sensor.py, line 7) Successful config (partial) 9:32 PM components/hassio/__init__.py (ERROR) Testing configuration at /config ERROR:homeassistant.scripts.check_config:BURB Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 207, in check res['components'] = check_ha_config_file(hass) File "/usr/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 372, in check_ha_config_file platform = loader.get_platform(hass, domain, p_name) File "/usr/lib/python3.6/site-packages/homeassistant/loader.py", line 58, in get_platform return get_component(hass, PLATFORM_FORMAT.format(domain, platform)) File "/usr/lib/python3.6/site-packages/homeassistant/loader.py", line 86, in get_component module = importlib.import_module(path) File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 674, in exec_module File "<frozen importlib._bootstrap_external>", line 781, in get_code File "<frozen importlib._bootstrap_external>", line 741, in source_to_code File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/config/custom_components/binary_sensor/dlink_motion_sensor.py", line 7 <!DOCTYPE html> ^ SyntaxError: invalid syntax Fatal error while loading config: invalid syntax (dlink_motion_sensor.py, line 7) Failed config General Errors: - invalid syntax (dlink_motion_sensor.py, line 7) Successful config (partial) 9:30 PM components/hassio/__init__.py (ERROR) Testing configuration at /config ERROR:homeassistant.scripts.check_config:BURB Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 207, in check res['components'] = check_ha_config_file(hass) File "/usr/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 372, in check_ha_config_file platform = loader.get_platform(hass, domain, p_name) File "/usr/lib/python3.6/site-packages/homeassistant/loader.py", line 58, in get_platform return get_component(hass, PLATFORM_FORMAT.format(domain, platform)) File "/usr/lib/python3.6/site-packages/homeassistant/loader.py", line 86, in get_component module = importlib.import_module(path) File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 674, in exec_module File "<frozen importlib._bootstrap_external>", line 781, in get_code File "<frozen importlib._bootstrap_external>", line 741, in source_to_code File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/config/custom_components/binary_sensor/dlink_motion_sensor.py", line 7 <!DOCTYPE html> ^ SyntaxError: invalid syntax Fatal error while loading config: invalid syntax (dlink_motion_sensor.py, line 7) Failed config General Errors: - invalid syntax (dlink_motion_sensor.py, line 7) Successful config (partial) 9:27 PM components/hassio/__init__.py (ERROR) Testing configuration at /config ERROR:homeassistant.scripts.check_config:BURB Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 207, in check res['components'] = check_ha_config_file(hass) File "/usr/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 372, in check_ha_config_file platform = loader.get_platform(hass, domain, p_name) File "/usr/lib/python3.6/site-packages/homeassistant/loader.py", line 58, in get_platform return get_component(hass, PLATFORM_FORMAT.format(domain, platform)) File "/usr/lib/python3.6/site-packages/homeassistant/loader.py", line 86, in get_component module = importlib.import_module(path) File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 674, in exec_module File "<frozen importlib._bootstrap_external>", line 781, in get_code File "<frozen importlib._bootstrap_external>", line 741, in source_to_code File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/config/custom_components/binary_sensor/dlink_motion_sensor.py", line 7 <!DOCTYPE html> ^ SyntaxError: invalid syntax Fatal error while loading config: invalid syntax (dlink_motion_sensor.py, line 7) Failed config General Errors: - invalid syntax (dlink_motion_sensor.py, line 7) Successful config (partial) 9:26 PM components/hassio/__init__.py (ERROR) Error handling request 9:21 PM loader.py (ERROR) Error handling request 9:17 PM loader.py (ERROR)
Let me know if I can provide any more information. Just a thought also but couldnt updates to the firmware be blocked say with your router.

Thanks to anybody that may be still listening


#66

can you specify wich device did you buy?


#67

The alarm cancelation delay is 30s, can I lower it to 10s?


#68

So I tried to install this. I added two files in :\custom_components\binary_sensor as instructed and I added in configuration.yaml the code below. This is the error I am getting… Any idea? Thanks…

binary_sensor: 
  - platform: dlink_motion_sensor
    name: Hodnik sensor
    host: !secret dlink_host
    password: !secret dlink_pin






Log Details (ERROR)
Thu Oct 04 2018 20:29:18 GMT+0200 (Central European Summer Time)

INFO:homeassistant.util.package:Attempting install of colorlog==3.1.4
Testing configuration at /config
ERROR:homeassistant.scripts.check_config:BURB
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 207, in check
    res['components'] = check_ha_config_file(hass)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 372, in check_ha_config_file
    platform = loader.get_platform(hass, domain, p_name)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/loader.py", line 60, in get_platform
    return get_component(hass, PLATFORM_FORMAT.format(domain, platform))
  File "/usr/local/lib/python3.6/site-packages/homeassistant/loader.py", line 92, in get_component
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/binary_sensor/dlink_motion_sensor.py", line 9
    <!DOCTYPE html>
    ^
SyntaxError: invalid syntax
Fatal error while loading config: invalid syntax (dlink_motion_sensor.py, line 9)
Failed config
  General Errors: 
    - invalid syntax (dlink_motion_sensor.py, line 9)
Successful config (partial)

#69

I have the HS 105 but I’ll pull it out and have a look at it. I thought I would not get an answer on this thread

Edit: that was completely wrong its the dch-s150a1


#70

Thank you your code is working for me!

And

PNG

Can you share a sample automation for this? I’m hoping to use it to turn lights on and then after a certain time turn them off - e.g. two state no detection of motion and elapsed time


#71

Ignore me - I have done one

  - alias: Turn on kitchen light when there is movement
    trigger:
      platform: state
      entity_id: binary_sensor.kitchen_sensor
      from: 'off'
      to: 'on'
    condition:
        condition: or  # 'when dark' condition: either after sunset or before sunrise
        conditions:
          - condition: sun
            after: sunset
          - condition: sun
            before: sunrise
    action:
      service: homeassistant.turn_on
      entity_id: switch.KitchenLighting
  
  - alias: Turn off kitchen light 10 minutes after last movement
    trigger:
      platform: state
      entity_id: binary_sensor.kitchen_sensor
      to: 'off'
      from: 'on'
      for:
        minutes: 5
    condition:
        condition: or  # 'when dark' condition: either after sunset or before sunrise
        conditions:
          - condition: sun
            after: sunset
          - condition: sun
            before: sunrise
    action:
      service: homeassistant.turn_off
      entity_id: switch.KitchenLighting

#72

Any idea how you access the last motion action data into a sensor?


#73

I set up the configuration as mentioned and the sensor showed up on my entities list.
I cant get it to change from off though.

Do i need to include all 3 files into my binary_sensor folder? or just the dlink_new and the dlink_motion_sensor?

Thanks in advance


#74

just the dlink_new and the dlink_motion_sensor, must be the right format saved, add template in configuration.yaml:
binary_sensor:

  • platform: dlink_motion_sensor
    name: Kitchen sensor
    host: !secret motion_kitchen_host
    password: !secret motion_kitchen_password

#75

Copy raw file to python and then save, must be the right format


#76

Hi,

i’m approching now the automations’s world and i trying to configure in HA a d-link motion sensor. When i try to install dlink_new.py i encounter this error:

GetAPClientSettings
dlink_2.py:261: RuntimeWarning: coroutine ‘ClientSession.close’ was never awaited
session.close()
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x75b8efb0>
ERROR:asyncio:Unclosed connector
connections: [’[(<aiohttp.client_proto.ResponseHandler object at 0x75ba33e8>, 2929.093215282)]’]

Can you help me, please?


#77

Stop ha, copy the file in folder and restart


#78

Thanks, now it works.


#79

Does anyone know if this will work with the DCH-S160 (water sensor)?


#80

Has 0.85.0 update broken this for anyone else?


#81

Nevermind, just needed to update the sensor name due to hyphen in d-link


#82

Tested with 1.23 firmware on DCH-S 150

@postlund - Any possibility this component can be added officially to Home Assistant - it works for me flawlessly


#83

It would be possible but requires a bit of work to extract the library and publish as a pypi package. One would think this over twice since it would probably not be hard to make the library work with other d-link products, just to avoid naming it badly. I will think about it.