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

@ -19,7 +19,7 @@ from .const import (
from .device import HomematicipGenericDevice # noqa: F401 from .device import HomematicipGenericDevice # noqa: F401
from .hap import HomematicipAuth, HomematicipHAP # noqa: F401 from .hap import HomematicipAuth, HomematicipHAP # noqa: F401
REQUIREMENTS = ['homematicip==0.10.4'] REQUIREMENTS = ['homematicip==0.10.5']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View file

@ -7,11 +7,10 @@ https://home-assistant.io/components/sensor.homematicip_cloud/
import logging import logging
from homeassistant.components.homematicip_cloud import ( from homeassistant.components.homematicip_cloud import (
HMIPC_HAPID, HomematicipGenericDevice) DOMAIN as HMIPC_DOMAIN, HMIPC_HAPID, HomematicipGenericDevice)
from homeassistant.components.homematicip_cloud import DOMAIN as HMIPC_DOMAIN
from homeassistant.const import ( from homeassistant.const import (
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE,
TEMP_CELSIUS) DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS)
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -36,7 +35,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
AsyncHeatingThermostat, AsyncTemperatureHumiditySensorWithoutDisplay, AsyncHeatingThermostat, AsyncTemperatureHumiditySensorWithoutDisplay,
AsyncTemperatureHumiditySensorDisplay, AsyncMotionDetectorIndoor, AsyncTemperatureHumiditySensorDisplay, AsyncMotionDetectorIndoor,
AsyncTemperatureHumiditySensorOutdoor, AsyncTemperatureHumiditySensorOutdoor,
AsyncMotionDetectorPushButton) AsyncMotionDetectorPushButton, AsyncLightSensor,
AsyncPlugableSwitchMeasuring, AsyncBrandSwitchMeasuring,
AsyncFullFlushSwitchMeasuring)
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)]
@ -51,6 +52,12 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
if isinstance(device, (AsyncMotionDetectorIndoor, if isinstance(device, (AsyncMotionDetectorIndoor,
AsyncMotionDetectorPushButton)): AsyncMotionDetectorPushButton)):
devices.append(HomematicipIlluminanceSensor(home, device)) 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: if devices:
async_add_entities(devices) async_add_entities(devices)
@ -184,3 +191,30 @@ class HomematicipIlluminanceSensor(HomematicipGenericDevice):
def unit_of_measurement(self): def unit_of_measurement(self):
"""Return the unit this state is expressed in.""" """Return the unit this state is expressed in."""
return 'lx' 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'

View file

@ -538,7 +538,7 @@ homeassistant-pyozw==0.1.2
homekit==0.12.2 homekit==0.12.2
# homeassistant.components.homematicip_cloud # homeassistant.components.homematicip_cloud
homematicip==0.10.4 homematicip==0.10.5
# homeassistant.components.google # homeassistant.components.google
# homeassistant.components.remember_the_milk # homeassistant.components.remember_the_milk

View file

@ -122,7 +122,7 @@ home-assistant-frontend==20190203.0
homekit==0.12.2 homekit==0.12.2
# homeassistant.components.homematicip_cloud # homeassistant.components.homematicip_cloud
homematicip==0.10.4 homematicip==0.10.5
# homeassistant.components.influxdb # homeassistant.components.influxdb
# homeassistant.components.sensor.influxdb # homeassistant.components.sensor.influxdb