Add additional devices and features to Homematic IP (#20747)

* Homematic IP: updated dependency homematicip to 0.10.5

* Homematic IP: Added LightSensor

* Homematic IP: Added power measure for XXXSwitchMeasuring

* reverted unnessessary change

* reverted unnessessary change

* removed device_class from core

* Removed optional property device_class

* Added description for property

* Changed comment to fix travis build

* Changed comment to fix travis build
This commit is contained in:
Markus Jankowski 2019-02-08 12:43:48 +01:00 committed by Martin Hjelmare
parent d5fad33599
commit ca0e5a75ec
4 changed files with 42 additions and 8 deletions

View file

@ -7,11 +7,10 @@ https://home-assistant.io/components/sensor.homematicip_cloud/
import logging
from homeassistant.components.homematicip_cloud import (
HMIPC_HAPID, HomematicipGenericDevice)
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
DOMAIN as HMIPC_DOMAIN, HMIPC_HAPID, HomematicipGenericDevice)
from homeassistant.const import (
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_TEMPERATURE,
TEMP_CELSIUS)
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE,
DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS)
_LOGGER = logging.getLogger(__name__)
@ -36,7 +35,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
AsyncHeatingThermostat, AsyncTemperatureHumiditySensorWithoutDisplay,
AsyncTemperatureHumiditySensorDisplay, AsyncMotionDetectorIndoor,
AsyncTemperatureHumiditySensorOutdoor,
AsyncMotionDetectorPushButton)
AsyncMotionDetectorPushButton, AsyncLightSensor,
AsyncPlugableSwitchMeasuring, AsyncBrandSwitchMeasuring,
AsyncFullFlushSwitchMeasuring)
home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home
devices = [HomematicipAccesspointStatus(home)]
@ -51,6 +52,12 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
if isinstance(device, (AsyncMotionDetectorIndoor,
AsyncMotionDetectorPushButton)):
devices.append(HomematicipIlluminanceSensor(home, device))
if isinstance(device, AsyncLightSensor):
devices.append(HomematicipLightSensor(home, device))
if isinstance(device, (AsyncPlugableSwitchMeasuring,
AsyncBrandSwitchMeasuring,
AsyncFullFlushSwitchMeasuring)):
devices.append(HomematicipPowerSensor(home, device))
if devices:
async_add_entities(devices)
@ -184,3 +191,30 @@ class HomematicipIlluminanceSensor(HomematicipGenericDevice):
def unit_of_measurement(self):
"""Return the unit this state is expressed in."""
return 'lx'
class HomematicipLightSensor(HomematicipIlluminanceSensor):
"""Represenation of a HomematicIP Illuminance device."""
@property
def state(self):
"""Return the state."""
return self._device.averageIllumination
class HomematicipPowerSensor(HomematicipGenericDevice):
"""Represenation of a HomematicIP power measuring device."""
def __init__(self, home, device):
"""Initialize the device."""
super().__init__(home, device, 'Power')
@property
def state(self):
"""Represenation of the HomematicIP power comsumption value."""
return self._device.currentPowerConsumption
@property
def unit_of_measurement(self):
"""Return the unit this state is expressed in."""
return 'W'