Add Delta Counter of HmIP-SPDR to Homematic IP Cloud (#26538)
parent
702e63e6e8
commit
ff136a19d9
|
@ -10,6 +10,7 @@ from homematicip.aio.device import (
|
||||||
AsyncMotionDetectorIndoor,
|
AsyncMotionDetectorIndoor,
|
||||||
AsyncMotionDetectorOutdoor,
|
AsyncMotionDetectorOutdoor,
|
||||||
AsyncMotionDetectorPushButton,
|
AsyncMotionDetectorPushButton,
|
||||||
|
AsyncPassageDetector,
|
||||||
AsyncPlugableSwitchMeasuring,
|
AsyncPlugableSwitchMeasuring,
|
||||||
AsyncPresenceDetectorIndoor,
|
AsyncPresenceDetectorIndoor,
|
||||||
AsyncTemperatureHumiditySensorDisplay,
|
AsyncTemperatureHumiditySensorDisplay,
|
||||||
|
@ -38,6 +39,8 @@ from .device import ATTR_MODEL_TYPE
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
ATTR_LEFT_COUNTER = "left_counter"
|
||||||
|
ATTR_RIGHT_COUNTER = "right_counter"
|
||||||
ATTR_TEMPERATURE_OFFSET = "temperature_offset"
|
ATTR_TEMPERATURE_OFFSET = "temperature_offset"
|
||||||
ATTR_WIND_DIRECTION = "wind_direction"
|
ATTR_WIND_DIRECTION = "wind_direction"
|
||||||
ATTR_WIND_DIRECTION_VARIATION = "wind_direction_variation_in_degree"
|
ATTR_WIND_DIRECTION_VARIATION = "wind_direction_variation_in_degree"
|
||||||
|
@ -100,6 +103,8 @@ async def async_setup_entry(
|
||||||
devices.append(HomematicipWindspeedSensor(home, device))
|
devices.append(HomematicipWindspeedSensor(home, device))
|
||||||
if isinstance(device, (AsyncWeatherSensorPlus, AsyncWeatherSensorPro)):
|
if isinstance(device, (AsyncWeatherSensorPlus, AsyncWeatherSensorPro)):
|
||||||
devices.append(HomematicipTodayRainSensor(home, device))
|
devices.append(HomematicipTodayRainSensor(home, device))
|
||||||
|
if isinstance(device, AsyncPassageDetector):
|
||||||
|
devices.append(HomematicipPassageDetectorDeltaCounter(home, device))
|
||||||
|
|
||||||
if devices:
|
if devices:
|
||||||
async_add_entities(devices)
|
async_add_entities(devices)
|
||||||
|
@ -338,6 +343,29 @@ class HomematicipTodayRainSensor(HomematicipGenericDevice):
|
||||||
return "mm"
|
return "mm"
|
||||||
|
|
||||||
|
|
||||||
|
class HomematicipPassageDetectorDeltaCounter(HomematicipGenericDevice):
|
||||||
|
"""Representation of a HomematicIP passage detector delta counter."""
|
||||||
|
|
||||||
|
def __init__(self, home: AsyncHome, device) -> None:
|
||||||
|
"""Initialize the device."""
|
||||||
|
super().__init__(home, device)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state(self) -> int:
|
||||||
|
"""Representation of the HomematicIP passage detector delta counter value."""
|
||||||
|
return self._device.leftRightCounterDelta
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_state_attributes(self):
|
||||||
|
"""Return the state attributes of the delta counter."""
|
||||||
|
state_attr = super().device_state_attributes
|
||||||
|
|
||||||
|
state_attr[ATTR_LEFT_COUNTER] = self._device.leftCounter
|
||||||
|
state_attr[ATTR_RIGHT_COUNTER] = self._device.rightCounter
|
||||||
|
|
||||||
|
return state_attr
|
||||||
|
|
||||||
|
|
||||||
def _get_wind_direction(wind_direction_degree: float) -> str:
|
def _get_wind_direction(wind_direction_degree: float) -> str:
|
||||||
"""Convert wind direction degree to named direction."""
|
"""Convert wind direction degree to named direction."""
|
||||||
if 11.25 <= wind_direction_degree < 33.75:
|
if 11.25 <= wind_direction_degree < 33.75:
|
||||||
|
|
Loading…
Reference in New Issue