D-Link Water Sensor DCH-S160

Relatively new to HA, but wondering usually how do I go about adding a new device component that isn’t on the list yet? I am referring to my D-Link Water Sensor DCH-S160

Thanks

I don’t use it but the webpage for the sensor says you can use it in ifttt. Ha has a ifttt component i think.

Thanks, I will look into IFTTT

There is a component that supports the DCH-S150 motion sensor made by @postlund.
It works like a charm for me.

Maybe it could work for the S160 leak sensor too?
Perhaps without any modification?
I have both, will try to check and come back to you.

@postlund got any ideas?

It will not work out-of-the box as it most likely uses another service to determine state. But I assume that HNAP is used in the same way so it shouldn’t be that hard to make some adjustments. If someone could provide a list of supported actions (python3 dlink.py <IP> <PIN> actions), that would be a start.

I am assuming this cannot be executed on an RPi with hass.io on it right?

You will need python for it to work, might be possible to add via app but I don’t know. You can run the command on any machine on the same network though.

Ah, got it, will try to execute it when i get home and give you the results.
Thanks for the help

@krash Were you able to test?

Nop, just got back home from a vacation and the sensor is tucked under the kitchen cabinets (I need to get the pin)

Thanks for the bumb though, I’ll get on it soon and get back to you guys.

I tried this today and got this:

Supported actions:
Reboot
SetFactoryDefault
IsDeviceReady
GetDeviceSettings
SetDeviceSettings
GetDeviceSettings2
SetDeviceSettings2
GetGroupSettings
SetGroupSettings
GetSystemLogs
CleanSystemLogs
GetModuleSchedule
SetModuleSchedule
GetModuleEnabled
SetModuleEnabled
GetModuleProfile
SetModuleProfile
GetModuleSOAPActions
GetTimeSettings
SetTimeSettings
GetModuleGroup
SetModuleGroup
GetScheduleSettings
SetScheduleSettings
GetRecursiveSchedule
SetRecursiveSchedule
GetFirmwareStatus
GetFirmwareValidation
StartFirmwareDownload
PollingFirmwareDownload
CheckNewFirmware
SettriggerADIC
GetInternetSettings
GetCurrentInternetStatus
GetWLanRadios
SetTriggerWirelessSiteSurvey
GetSiteSurvey
SetAPClientSettings
GetAPClientSettings

Not quite obvious which action is interesting here. Maybe you could try log instead of actions? Could maybe be possible to extract from there.

I would just use this command?

python3 dlink.py <IP> <PIN> log

I tried that but got this:

ERROR:main:parsed: OrderedDict([(‘html’, OrderedDict([(‘@xmlns’, ‘XHTML namespace’), (‘@xml:lang’, ‘en’), (‘@lang’, ‘en’), (‘head’, OrderedDict([(‘title’, ‘500 - Internal Server Error’)])), (‘body’, OrderedDict([(‘h1’, ‘500 - Internal Server Error’)]))]))])
ERROR:main:Got an error, resetting private key
Traceback (most recent call last):
File “dlink.py”, line 105, in call
result = yield from self.soap().call(method, **kwargs)
File “dlink.py”, line 230, in call
raise Exception(‘probably a bad response’)
Exception: probably a bad response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “dlink.py”, line 263, in
loop.run_until_complete(_print_latest_motion())
File “/usr/lib/python3.6/asyncio/base_events.py”, line 484, in run_until_complete
return future.result()
File “dlink.py”, line 259, in _print_latest_motion
log = yield from motion.system_log()
File “dlink.py”, line 175, in system_log
PageOffset=1, StartTime=0, EndTime=‘All’)
File “dlink.py”, line 109, in call
self._bad_response()
File “dlink.py”, line 115, in _bad_response
raise Exception(‘got error response from device’)
Exception: got error response from device
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f335d0537b8>
ERROR:asyncio:Unclosed connector
connections: [‘[(<aiohttp.client_proto.ResponseHandler object at 0x7f335b121348>, 985302.397417762)]’]
connector: <aiohttp.connector.TCPConnector object at 0x7f335c0b7b00>

Ok, interesting. Something might be different compared to the S150 then. I took a peek at the firmware but I can’t say that I can see what.

I am wondering if I got locked out somehow. I tried using actions again and it isn’t working. Will try again later.

dlink.py:261: RuntimeWarning: coroutine ‘ClientSession.close’ was never awaited

session.close()

ERROR:asyncio:Unclosed client session

client_session: <aiohttp.client.ClientSession object at 0x7f187c01c828>

ERROR:asyncio:Unclosed connector

connections: [‘[(<aiohttp.client_proto.ResponseHandler object at 0x7f187a0ea348>, 988375.281289376)]’]

connector: <aiohttp.connector.TCPConnector object at 0x7f187b080b70>

I got actions working again but log still does not work.

Managed to get it to work and built an MQTT integration for Home Assistant so that alerts from the DCH-S160 Dlink Water Sensor can be handled in Home Assistant.

See here:

4 Likes

@postlund - any chance you can integrate the great work MichaelB2018 did to your custom_component?

It would probably be quite easy to do, since it’s fully based on my client code. But unfortunately I don’t have much time over to do so at the moment, but would love to see it happen.

Apologies if this should be self-evident, but I’m a noob and a diligent search didn’t help: how do I use this to monitor the dch-s160 (especially now that IFTT is going away and my basement just flooded last week)? More specifically, how /where does this get installed and triggered? I’m running hass in docker from docker hub with portainer on a synology.

Thanks in advance.