mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Add battery sensor to Homematic IP (#22630)
This commit is contained in:
parent
429e2cdde8
commit
6c14e7afa7
@ -29,8 +29,8 @@ 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,
|
AsyncDevice, AsyncShutterContact, AsyncMotionDetectorIndoor,
|
||||||
AsyncWaterSensor, AsyncRotaryHandleSensor,
|
AsyncSmokeDetector, AsyncWaterSensor, AsyncRotaryHandleSensor,
|
||||||
AsyncMotionDetectorPushButton, AsyncWeatherSensor,
|
AsyncMotionDetectorPushButton, AsyncWeatherSensor,
|
||||||
AsyncWeatherSensorPlus, AsyncWeatherSensorPro)
|
AsyncWeatherSensorPlus, AsyncWeatherSensorPro)
|
||||||
|
|
||||||
@ -56,6 +56,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
AsyncWeatherSensorPro)):
|
AsyncWeatherSensorPro)):
|
||||||
devices.append(HomematicipStormSensor(home, device))
|
devices.append(HomematicipStormSensor(home, device))
|
||||||
devices.append(HomematicipSunshineSensor(home, device))
|
devices.append(HomematicipSunshineSensor(home, device))
|
||||||
|
if isinstance(device, AsyncDevice) and device.lowBat is not None:
|
||||||
|
devices.append(HomematicipBatterySensor(home, device))
|
||||||
|
|
||||||
for group in home.groups:
|
for group in home.groups:
|
||||||
if isinstance(group, AsyncSecurityGroup):
|
if isinstance(group, AsyncSecurityGroup):
|
||||||
@ -197,6 +199,24 @@ class HomematicipSunshineSensor(HomematicipGenericDevice, BinarySensorDevice):
|
|||||||
return attr
|
return attr
|
||||||
|
|
||||||
|
|
||||||
|
class HomematicipBatterySensor(HomematicipGenericDevice, BinarySensorDevice):
|
||||||
|
"""Representation of a HomematicIP Cloud low battery sensor."""
|
||||||
|
|
||||||
|
def __init__(self, home, device):
|
||||||
|
"""Initialize battery sensor."""
|
||||||
|
super().__init__(home, device, 'Battery')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self):
|
||||||
|
"""Return the class of this sensor."""
|
||||||
|
return 'battery'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_on(self):
|
||||||
|
"""Return true if battery is low."""
|
||||||
|
return self._device.lowBat
|
||||||
|
|
||||||
|
|
||||||
class HomematicipSecurityZoneSensorGroup(HomematicipGenericDevice,
|
class HomematicipSecurityZoneSensorGroup(HomematicipGenericDevice,
|
||||||
BinarySensorDevice):
|
BinarySensorDevice):
|
||||||
"""Representation of a HomematicIP Cloud security zone group."""
|
"""Representation of a HomematicIP Cloud security zone group."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user