\config\custom_components\dlink_motion_sensor
finally it works! thanks
Is this just working with sensors on my network?
Is there any way to control a sensor that I have in another house different than my HA?
Thanks!
This component is accessing directly the device not the dlink cloud service. So if your sensor has no public IP address, which would be a security risk, then NO.
Since they are going to stop IFTTT support for the Dlink motion sensor DCH-S150, this might become important. I just put my (corrected) summary here and a link to my files on dropbox, since the github files seem to no longer be available.
So: Put the files in the config folder âcustom_components/dlink_motion_sensorâ (make the folders). Then add an empty file called âinit.pyâ to the same folder, otherwise it wonât work. Then 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. Lastly, do a system reboot (not just the home assistant server).
Files:
Files D-link sensor
edit
Iâve changed the code to solve the âBinarySensorDevice is deprecatedâ warning
In light of the upcoming termination of IFTTT support maybe someone could convert it in an âofficialâ component with a support of motion sensor DCH-S150 and water sensor DCH-S160?
that would be ideal, Iâm also getting warnings with the code (BinarySensorDevice is deprecated, modify DlinkMotionSensor to extend BinarySensorEntity). It still works for now, however Iâm getting some errors which might be related as well.
Hi, I just swapped the BinarySensorDevice with BinarySensorEntity and I donât seem to get the error anymore. Not sure if that solves it correctly or not but seems fine.
That will solve it. I believe this was mentioned in the release notes for 0.110.
MIne stopped working after latests update with these errors. Any idead?
2020-06-10 15:21:33 WARNING (MainThread) [homeassistant.components.binary_sensor] Setup of binary_sensor platform dlink_motion_sensor is taking over 10 seconds.
2020-06-10 15:21:35 ERROR (MainThread) [custom_components.dlink_motion_sensor.dlink] Got an error, resetting private key
2020-06-10 15:21:35 ERROR (MainThread) [custom_components.dlink_motion_sensor.binary_sensor] failed to update motion sensor
Traceback (most recent call last):
File "/var/opt/homeassistant/custom_components/dlink_motion_sensor/dlink.py", line 105, in call
result = yield from self.soap().call(method, **kwargs)
File "/var/opt/homeassistant/custom_components/dlink_motion_sensor/dlink.py", line 225, in call
self.address, data=xml, headers=headers, timeout=10)
File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 504, in _request
await resp.start(conn)
File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 860, in start
self._continue = None
File "/usr/local/lib/python3.7/site-packages/aiohttp/helpers.py", line 586, in __exit__
raise asyncio.TimeoutError from None
concurrent.futures._base.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/opt/homeassistant/custom_components/dlink_motion_sensor/binary_sensor.py", line 93, in async_update
last_trigger = yield from self._motion_sensor.latest_trigger()
File "/var/opt/homeassistant/custom_components/dlink_motion_sensor/dlink.py", line 153, in latest_trigger
yield from self._cache_soap_actions()
File "/var/opt/homeassistant/custom_components/dlink_motion_sensor/dlink.py", line 180, in _cache_soap_actions
resp = yield from self.client.soap_actions(self.module_id)
File "/var/opt/homeassistant/custom_components/dlink_motion_sensor/dlink.py", line 94, in soap_actions
'GetModuleSOAPActions', ModuleID=module_id))
File "/var/opt/homeassistant/custom_components/dlink_motion_sensor/dlink.py", line 101, in call
yield from self.login()
File "/var/opt/homeassistant/custom_components/dlink_motion_sensor/dlink.py", line 57, in login
LoginPassword='', Captcha='')
File "/var/opt/homeassistant/custom_components/dlink_motion_sensor/dlink.py", line 109, in call
self._bad_response()
File "/var/opt/homeassistant/custom_components/dlink_motion_sensor/dlink.py", line 115, in _bad_response
raise Exception('got error response from device')
Exception: got error response from device
I solved my issue by uninstalling homeassistant, manually removing the entire homeassistant folder in python dist-packages folder, rebooting, reinstalling homeassistant and et voilla. it magically works.
Hey Iâm very new to home assistant. As a Matter is fact Iâm trying to get started with with only because I purchased the dlink sensor DCH-S150
I was using it with ifttt so far to trigger ewelink switches but they made it paid recently so trying to do it in home assistant. I bought 6 of those devices for my home so canât upgrade to different device. If someone can write a quite sum of now to set up the sensor in home assistant itâll be really helpful
It seems like there is a new error with 0.113 and the component doesnât work anymore:
2020-07-22 21:39:42 ERROR (MainThread) [custom_components.dlink_motion_sensor.binary_sensor] failed to update motion sensor
Traceback (most recent call last):
File "/config/custom_components/dlink_motion_sensor/binary_sensor.py", line 93, in async_update
last_trigger = yield from self._motion_sensor.latest_trigger()
File "/config/custom_components/dlink_motion_sensor/dlink.py", line 153, in latest_trigger
yield from self._cache_soap_actions()
File "/config/custom_components/dlink_motion_sensor/dlink.py", line 180, in _cache_soap_actions
resp = yield from self.client.soap_actions(self.module_id)
File "/config/custom_components/dlink_motion_sensor/dlink.py", line 93, in soap_actions
return (yield from self.call(
File "/config/custom_components/dlink_motion_sensor/dlink.py", line 101, in call
yield from self.login()
File "/config/custom_components/dlink_motion_sensor/dlink.py", line 65, in login
self._private_key = _hmac(public_key + str(self.password), challenge)
File "/config/custom_components/dlink_motion_sensor/dlink.py", line 24, in _hmac
return hmac.new(key.encode('utf-8'),
File "/usr/local/lib/python3.8/hmac.py", line 153, in new
return HMAC(key, msg, digestmod)
File "/usr/local/lib/python3.8/hmac.py", line 51, in __init__
raise TypeError("Missing required parameter 'digestmod'.")
TypeError: Missing required parameter 'digestmod'.
Same problem here with 0.113
It is due to Python 3.8 where digestmod
is required to provide. Would someone be able to adapt the code for 3.8?
Line 25 of config/custom_components/dlink_motion_sensor/dlink.py should be changed to message.encode(âutf-8â),âMD5â).hexdigest().upper()
This worked for me. From what I worked out it previously defaulted to MD5 if not defined but now it has to be stipulated.
I created a PR:
Please verify and let me know if it works!
Right, so⊠I have gotten a lot of questions regarding my custom component. Currently, I do not use my DCH-S150, but I left the code for the component for others to use. Now I decided to extract it into its own repository, which is compatible with HACS. So you can basically install it with HACS, but you do need to add it as a custom repository.
The code is available here:
Itâs the same one as in my hass-config
repo with some minor differences:
- Code is formatted with black
- Changed to async/await syntax
- Added manifest
- It has been renamed to
dlink_hnap
to open up for future device types
Other than that it should be the same. As I havenât tested it, I need your help with that. If you try it out, please report back in https://github.com/postlund/dlink_hnap/issues/1.
If you find bugs, please write an issue on GitHub. Do not report it here! Once I have gotten some feedback and it seems to work good enough, I will send a PR to have it included in HACS natively. So you donât have to add it as a custom repo.
Works perfect. Kudos