mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Add Presence Detector Indoor to Homematic IP (#23755)
* Add presence detector indoor use device classes constants * Add illuminance * isort
This commit is contained in:
parent
0e9d71f232
commit
118d3bc11c
@ -3,14 +3,18 @@ import logging
|
|||||||
|
|
||||||
from homematicip.aio.device import (
|
from homematicip.aio.device import (
|
||||||
AsyncDevice, AsyncMotionDetectorIndoor, AsyncMotionDetectorOutdoor,
|
AsyncDevice, AsyncMotionDetectorIndoor, AsyncMotionDetectorOutdoor,
|
||||||
AsyncMotionDetectorPushButton, AsyncRotaryHandleSensor,
|
AsyncMotionDetectorPushButton, AsyncPresenceDetectorIndoor,
|
||||||
AsyncShutterContact, AsyncSmokeDetector, AsyncWaterSensor,
|
AsyncRotaryHandleSensor, AsyncShutterContact, AsyncSmokeDetector,
|
||||||
AsyncWeatherSensor, AsyncWeatherSensorPlus, AsyncWeatherSensorPro)
|
AsyncWaterSensor, AsyncWeatherSensor, AsyncWeatherSensorPlus,
|
||||||
|
AsyncWeatherSensorPro)
|
||||||
from homematicip.aio.group import AsyncSecurityGroup, AsyncSecurityZoneGroup
|
from homematicip.aio.group import AsyncSecurityGroup, AsyncSecurityZoneGroup
|
||||||
from homematicip.aio.home import AsyncHome
|
from homematicip.aio.home import AsyncHome
|
||||||
from homematicip.base.enums import SmokeDetectorAlarmType, WindowState
|
from homematicip.base.enums import SmokeDetectorAlarmType, WindowState
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import BinarySensorDevice
|
from homeassistant.components.binary_sensor import (
|
||||||
|
DEVICE_CLASS_BATTERY, DEVICE_CLASS_DOOR, DEVICE_CLASS_LIGHT,
|
||||||
|
DEVICE_CLASS_MOISTURE, DEVICE_CLASS_MOTION, DEVICE_CLASS_PRESENCE,
|
||||||
|
DEVICE_CLASS_SAFETY, DEVICE_CLASS_SMOKE, BinarySensorDevice)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
@ -47,6 +51,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry,
|
|||||||
AsyncMotionDetectorOutdoor,
|
AsyncMotionDetectorOutdoor,
|
||||||
AsyncMotionDetectorPushButton)):
|
AsyncMotionDetectorPushButton)):
|
||||||
devices.append(HomematicipMotionDetector(home, device))
|
devices.append(HomematicipMotionDetector(home, device))
|
||||||
|
if isinstance(device, AsyncPresenceDetectorIndoor):
|
||||||
|
devices.append(HomematicipPresenceDetector(home, device))
|
||||||
if isinstance(device, AsyncSmokeDetector):
|
if isinstance(device, AsyncSmokeDetector):
|
||||||
devices.append(HomematicipSmokeDetector(home, device))
|
devices.append(HomematicipSmokeDetector(home, device))
|
||||||
if isinstance(device, AsyncWaterSensor):
|
if isinstance(device, AsyncWaterSensor):
|
||||||
@ -77,7 +83,7 @@ class HomematicipShutterContact(HomematicipGenericDevice, BinarySensorDevice):
|
|||||||
@property
|
@property
|
||||||
def device_class(self) -> str:
|
def device_class(self) -> str:
|
||||||
"""Return the class of this sensor."""
|
"""Return the class of this sensor."""
|
||||||
return 'door'
|
return DEVICE_CLASS_DOOR
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
@ -95,7 +101,7 @@ class HomematicipMotionDetector(HomematicipGenericDevice, BinarySensorDevice):
|
|||||||
@property
|
@property
|
||||||
def device_class(self) -> str:
|
def device_class(self) -> str:
|
||||||
"""Return the class of this sensor."""
|
"""Return the class of this sensor."""
|
||||||
return 'motion'
|
return DEVICE_CLASS_MOTION
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
@ -105,13 +111,30 @@ class HomematicipMotionDetector(HomematicipGenericDevice, BinarySensorDevice):
|
|||||||
return self._device.motionDetected
|
return self._device.motionDetected
|
||||||
|
|
||||||
|
|
||||||
|
class HomematicipPresenceDetector(HomematicipGenericDevice,
|
||||||
|
BinarySensorDevice):
|
||||||
|
"""Representation of a HomematicIP Cloud presence detector."""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self) -> str:
|
||||||
|
"""Return the class of this sensor."""
|
||||||
|
return DEVICE_CLASS_PRESENCE
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_on(self) -> bool:
|
||||||
|
"""Return true if presence is detected."""
|
||||||
|
if hasattr(self._device, 'sabotage') and self._device.sabotage:
|
||||||
|
return True
|
||||||
|
return self._device.presenceDetected
|
||||||
|
|
||||||
|
|
||||||
class HomematicipSmokeDetector(HomematicipGenericDevice, BinarySensorDevice):
|
class HomematicipSmokeDetector(HomematicipGenericDevice, BinarySensorDevice):
|
||||||
"""Representation of a HomematicIP Cloud smoke detector."""
|
"""Representation of a HomematicIP Cloud smoke detector."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self) -> str:
|
def device_class(self) -> str:
|
||||||
"""Return the class of this sensor."""
|
"""Return the class of this sensor."""
|
||||||
return 'smoke'
|
return DEVICE_CLASS_SMOKE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
@ -126,7 +149,7 @@ class HomematicipWaterDetector(HomematicipGenericDevice, BinarySensorDevice):
|
|||||||
@property
|
@property
|
||||||
def device_class(self) -> str:
|
def device_class(self) -> str:
|
||||||
"""Return the class of this sensor."""
|
"""Return the class of this sensor."""
|
||||||
return 'moisture'
|
return DEVICE_CLASS_MOISTURE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
@ -162,7 +185,7 @@ class HomematicipRainSensor(HomematicipGenericDevice, BinarySensorDevice):
|
|||||||
@property
|
@property
|
||||||
def device_class(self) -> str:
|
def device_class(self) -> str:
|
||||||
"""Return the class of this sensor."""
|
"""Return the class of this sensor."""
|
||||||
return 'moisture'
|
return DEVICE_CLASS_MOISTURE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
@ -180,7 +203,7 @@ class HomematicipSunshineSensor(HomematicipGenericDevice, BinarySensorDevice):
|
|||||||
@property
|
@property
|
||||||
def device_class(self) -> str:
|
def device_class(self) -> str:
|
||||||
"""Return the class of this sensor."""
|
"""Return the class of this sensor."""
|
||||||
return 'light'
|
return DEVICE_CLASS_LIGHT
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
@ -208,7 +231,7 @@ class HomematicipBatterySensor(HomematicipGenericDevice, BinarySensorDevice):
|
|||||||
@property
|
@property
|
||||||
def device_class(self) -> str:
|
def device_class(self) -> str:
|
||||||
"""Return the class of this sensor."""
|
"""Return the class of this sensor."""
|
||||||
return 'battery'
|
return DEVICE_CLASS_BATTERY
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
@ -229,7 +252,7 @@ class HomematicipSecurityZoneSensorGroup(HomematicipGenericDevice,
|
|||||||
@property
|
@property
|
||||||
def device_class(self) -> str:
|
def device_class(self) -> str:
|
||||||
"""Return the class of this sensor."""
|
"""Return the class of this sensor."""
|
||||||
return 'safety'
|
return DEVICE_CLASS_SAFETY
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
|
@ -6,7 +6,7 @@ from homematicip.aio.device import (
|
|||||||
AsyncHeatingThermostat, AsyncHeatingThermostatCompact, AsyncLightSensor,
|
AsyncHeatingThermostat, AsyncHeatingThermostatCompact, AsyncLightSensor,
|
||||||
AsyncMotionDetectorIndoor, AsyncMotionDetectorOutdoor,
|
AsyncMotionDetectorIndoor, AsyncMotionDetectorOutdoor,
|
||||||
AsyncMotionDetectorPushButton, AsyncPlugableSwitchMeasuring,
|
AsyncMotionDetectorPushButton, AsyncPlugableSwitchMeasuring,
|
||||||
AsyncTemperatureHumiditySensorDisplay,
|
AsyncPresenceDetectorIndoor, AsyncTemperatureHumiditySensorDisplay,
|
||||||
AsyncTemperatureHumiditySensorOutdoor,
|
AsyncTemperatureHumiditySensorOutdoor,
|
||||||
AsyncTemperatureHumiditySensorWithoutDisplay, AsyncWeatherSensor,
|
AsyncTemperatureHumiditySensorWithoutDisplay, AsyncWeatherSensor,
|
||||||
AsyncWeatherSensorPlus, AsyncWeatherSensorPro)
|
AsyncWeatherSensorPlus, AsyncWeatherSensorPro)
|
||||||
@ -55,6 +55,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry,
|
|||||||
if isinstance(device, (AsyncLightSensor, AsyncMotionDetectorIndoor,
|
if isinstance(device, (AsyncLightSensor, AsyncMotionDetectorIndoor,
|
||||||
AsyncMotionDetectorOutdoor,
|
AsyncMotionDetectorOutdoor,
|
||||||
AsyncMotionDetectorPushButton,
|
AsyncMotionDetectorPushButton,
|
||||||
|
AsyncPresenceDetectorIndoor,
|
||||||
AsyncWeatherSensor,
|
AsyncWeatherSensor,
|
||||||
AsyncWeatherSensorPlus,
|
AsyncWeatherSensorPlus,
|
||||||
AsyncWeatherSensorPro)):
|
AsyncWeatherSensorPro)):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user