From 05922ac56a6d03b51250691e38a28a79d5110652 Mon Sep 17 00:00:00 2001 From: Mattias Welponer <mattias@welponer.net> Date: Sat, 15 Sep 2018 21:28:50 +0200 Subject: [PATCH] Add new devices to HomematicIP Cloud (#16636) * Add support for outdoor temperature sensor and cleanup * Add support for rotary handle and water sensor * Fix comment --- .../binary_sensor/homematicip_cloud.py | 21 +++++++++++++++++-- .../components/sensor/homematicip_cloud.py | 16 +++++++------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/binary_sensor/homematicip_cloud.py b/homeassistant/components/binary_sensor/homematicip_cloud.py index dd22a835504..6c8b7ff191e 100644 --- a/homeassistant/components/binary_sensor/homematicip_cloud.py +++ b/homeassistant/components/binary_sensor/homematicip_cloud.py @@ -27,17 +27,20 @@ async def async_setup_platform( async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the HomematicIP Cloud binary sensor from a config entry.""" from homematicip.aio.device import ( - AsyncShutterContact, AsyncMotionDetectorIndoor, AsyncSmokeDetector) + AsyncShutterContact, AsyncMotionDetectorIndoor, AsyncSmokeDetector, + AsyncWaterSensor, AsyncRotaryHandleSensor) home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home devices = [] for device in home.devices: - if isinstance(device, AsyncShutterContact): + if isinstance(device, (AsyncShutterContact, AsyncRotaryHandleSensor)): devices.append(HomematicipShutterContact(home, device)) elif isinstance(device, AsyncMotionDetectorIndoor): devices.append(HomematicipMotionDetector(home, device)) elif isinstance(device, AsyncSmokeDetector): devices.append(HomematicipSmokeDetector(home, device)) + elif isinstance(device, AsyncWaterSensor): + devices.append(HomematicipWaterDetector(home, device)) if devices: async_add_entities(devices) @@ -91,3 +94,17 @@ class HomematicipSmokeDetector(HomematicipGenericDevice, BinarySensorDevice): def is_on(self): """Return true if smoke is detected.""" return self._device.smokeDetectorAlarmType != STATE_SMOKE_OFF + + +class HomematicipWaterDetector(HomematicipGenericDevice, BinarySensorDevice): + """Representation of a HomematicIP Cloud water detector.""" + + @property + def device_class(self): + """Return the class of this sensor.""" + return 'moisture' + + @property + def is_on(self): + """Return true if moisture or waterlevel is detected.""" + return self._device.moistureDetected or self._device.waterlevelDetected diff --git a/homeassistant/components/sensor/homematicip_cloud.py b/homeassistant/components/sensor/homematicip_cloud.py index 2b8365b8f64..73fef98fb76 100644 --- a/homeassistant/components/sensor/homematicip_cloud.py +++ b/homeassistant/components/sensor/homematicip_cloud.py @@ -32,20 +32,22 @@ async def async_setup_platform( async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the HomematicIP Cloud sensors from a config entry.""" - from homematicip.device import ( - HeatingThermostat, TemperatureHumiditySensorWithoutDisplay, - TemperatureHumiditySensorDisplay, MotionDetectorIndoor) + from homematicip.aio.device import ( + AsyncHeatingThermostat, AsyncTemperatureHumiditySensorWithoutDisplay, + AsyncTemperatureHumiditySensorDisplay, AsyncMotionDetectorIndoor, + AsyncTemperatureHumiditySensorOutdoor) home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home devices = [HomematicipAccesspointStatus(home)] for device in home.devices: - if isinstance(device, HeatingThermostat): + if isinstance(device, AsyncHeatingThermostat): devices.append(HomematicipHeatingThermostat(home, device)) - if isinstance(device, (TemperatureHumiditySensorDisplay, - TemperatureHumiditySensorWithoutDisplay)): + if isinstance(device, (AsyncTemperatureHumiditySensorDisplay, + AsyncTemperatureHumiditySensorWithoutDisplay, + AsyncTemperatureHumiditySensorOutdoor)): devices.append(HomematicipTemperatureSensor(home, device)) devices.append(HomematicipHumiditySensor(home, device)) - if isinstance(device, MotionDetectorIndoor): + if isinstance(device, AsyncMotionDetectorIndoor): devices.append(HomematicipIlluminanceSensor(home, device)) if devices: -- GitLab