mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
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
This commit is contained in:
parent
34deaf8849
commit
05922ac56a
@ -27,17 +27,20 @@ async def async_setup_platform(
|
|||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up the HomematicIP Cloud binary sensor from a config entry."""
|
"""Set up the HomematicIP Cloud binary sensor from a config entry."""
|
||||||
from homematicip.aio.device import (
|
from homematicip.aio.device import (
|
||||||
AsyncShutterContact, AsyncMotionDetectorIndoor, AsyncSmokeDetector)
|
AsyncShutterContact, AsyncMotionDetectorIndoor, AsyncSmokeDetector,
|
||||||
|
AsyncWaterSensor, AsyncRotaryHandleSensor)
|
||||||
|
|
||||||
home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home
|
home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home
|
||||||
devices = []
|
devices = []
|
||||||
for device in home.devices:
|
for device in home.devices:
|
||||||
if isinstance(device, AsyncShutterContact):
|
if isinstance(device, (AsyncShutterContact, AsyncRotaryHandleSensor)):
|
||||||
devices.append(HomematicipShutterContact(home, device))
|
devices.append(HomematicipShutterContact(home, device))
|
||||||
elif isinstance(device, AsyncMotionDetectorIndoor):
|
elif isinstance(device, AsyncMotionDetectorIndoor):
|
||||||
devices.append(HomematicipMotionDetector(home, device))
|
devices.append(HomematicipMotionDetector(home, device))
|
||||||
elif isinstance(device, AsyncSmokeDetector):
|
elif isinstance(device, AsyncSmokeDetector):
|
||||||
devices.append(HomematicipSmokeDetector(home, device))
|
devices.append(HomematicipSmokeDetector(home, device))
|
||||||
|
elif isinstance(device, AsyncWaterSensor):
|
||||||
|
devices.append(HomematicipWaterDetector(home, device))
|
||||||
|
|
||||||
if devices:
|
if devices:
|
||||||
async_add_entities(devices)
|
async_add_entities(devices)
|
||||||
@ -91,3 +94,17 @@ class HomematicipSmokeDetector(HomematicipGenericDevice, BinarySensorDevice):
|
|||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return true if smoke is detected."""
|
"""Return true if smoke is detected."""
|
||||||
return self._device.smokeDetectorAlarmType != STATE_SMOKE_OFF
|
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
|
||||||
|
@ -32,20 +32,22 @@ async def async_setup_platform(
|
|||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up the HomematicIP Cloud sensors from a config entry."""
|
"""Set up the HomematicIP Cloud sensors from a config entry."""
|
||||||
from homematicip.device import (
|
from homematicip.aio.device import (
|
||||||
HeatingThermostat, TemperatureHumiditySensorWithoutDisplay,
|
AsyncHeatingThermostat, AsyncTemperatureHumiditySensorWithoutDisplay,
|
||||||
TemperatureHumiditySensorDisplay, MotionDetectorIndoor)
|
AsyncTemperatureHumiditySensorDisplay, AsyncMotionDetectorIndoor,
|
||||||
|
AsyncTemperatureHumiditySensorOutdoor)
|
||||||
|
|
||||||
home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home
|
home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home
|
||||||
devices = [HomematicipAccesspointStatus(home)]
|
devices = [HomematicipAccesspointStatus(home)]
|
||||||
for device in home.devices:
|
for device in home.devices:
|
||||||
if isinstance(device, HeatingThermostat):
|
if isinstance(device, AsyncHeatingThermostat):
|
||||||
devices.append(HomematicipHeatingThermostat(home, device))
|
devices.append(HomematicipHeatingThermostat(home, device))
|
||||||
if isinstance(device, (TemperatureHumiditySensorDisplay,
|
if isinstance(device, (AsyncTemperatureHumiditySensorDisplay,
|
||||||
TemperatureHumiditySensorWithoutDisplay)):
|
AsyncTemperatureHumiditySensorWithoutDisplay,
|
||||||
|
AsyncTemperatureHumiditySensorOutdoor)):
|
||||||
devices.append(HomematicipTemperatureSensor(home, device))
|
devices.append(HomematicipTemperatureSensor(home, device))
|
||||||
devices.append(HomematicipHumiditySensor(home, device))
|
devices.append(HomematicipHumiditySensor(home, device))
|
||||||
if isinstance(device, MotionDetectorIndoor):
|
if isinstance(device, AsyncMotionDetectorIndoor):
|
||||||
devices.append(HomematicipIlluminanceSensor(home, device))
|
devices.append(HomematicipIlluminanceSensor(home, device))
|
||||||
|
|
||||||
if devices:
|
if devices:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user