Update homematicip_cloud with enum states (#15460)

* Update to next version with enum states

* Change to generic dimmer class

* Update of requirement files

* Update to hmip lib to v0.9.7

* Missing update of requirements files

* Cleanup of icon properties
This commit is contained in:
Mattias Welponer 2018-07-15 02:59:19 +02:00 committed by Martin Hjelmare
parent ca4f69f557
commit 6db069881b
6 changed files with 20 additions and 61 deletions

View File

@ -21,8 +21,6 @@ ATTR_EVENT_DELAY = 'event_delay'
ATTR_MOTION_DETECTED = 'motion_detected'
ATTR_ILLUMINATION = 'illumination'
HMIP_OPEN = 'open'
async def async_setup_platform(hass, config, async_add_devices,
discovery_info=None):
@ -61,11 +59,13 @@ class HomematicipShutterContact(HomematicipGenericDevice, BinarySensorDevice):
@property
def is_on(self):
"""Return true if the shutter contact is on/open."""
from homematicip.base.enums import WindowState
if self._device.sabotage:
return True
if self._device.windowState is None:
return None
return self._device.windowState.lower() == HMIP_OPEN
return self._device.windowState == WindowState.OPEN
class HomematicipMotionDetector(HomematicipGenericDevice, BinarySensorDevice):

View File

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

View File

@ -31,14 +31,14 @@ async def async_setup_platform(hass, config, async_add_devices,
async def async_setup_entry(hass, config_entry, async_add_devices):
"""Set up the HomematicIP lights from a config entry."""
from homematicip.aio.device import (
AsyncBrandSwitchMeasuring, AsyncPluggableDimmer)
AsyncBrandSwitchMeasuring, AsyncDimmer)
home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home
devices = []
for device in home.devices:
if isinstance(device, AsyncBrandSwitchMeasuring):
devices.append(HomematicipLightMeasuring(home, device))
elif isinstance(device, AsyncPluggableDimmer):
elif isinstance(device, AsyncDimmer):
devices.append(HomematicipDimmer(home, device))
if devices:

View File

@ -24,14 +24,6 @@ ATTR_TEMPERATURE = 'temperature'
ATTR_TEMPERATURE_OFFSET = 'temperature_offset'
ATTR_HUMIDITY = 'humidity'
HMIP_UPTODATE = 'up_to_date'
HMIP_VALVE_DONE = 'adaption_done'
HMIP_SABOTAGE = 'sabotage'
STATE_OK = 'ok'
STATE_LOW_BATTERY = 'low_battery'
STATE_SABOTAGE = 'sabotage'
async def async_setup_platform(hass, config, async_add_devices,
discovery_info=None):
@ -83,44 +75,17 @@ class HomematicipAccesspointStatus(HomematicipGenericDevice):
"""Device available."""
return self._home.connected
@property
def unit_of_measurement(self):
"""Return the unit this state is expressed in."""
return '%'
@property
def device_state_attributes(self):
"""Return the state attributes of the access point."""
return {}
class HomematicipDeviceStatus(HomematicipGenericDevice):
"""Representation of an HomematicIP device status."""
def __init__(self, home, device):
"""Initialize generic status device."""
super().__init__(home, device, 'Status')
@property
def icon(self):
"""Return the icon of the status device."""
if (hasattr(self._device, 'sabotage') and
self._device.sabotage == HMIP_SABOTAGE):
return 'mdi:alert'
elif self._device.lowBat:
return 'mdi:battery-outline'
elif self._device.updateState.lower() != HMIP_UPTODATE:
return 'mdi:refresh'
return 'mdi:check'
@property
def state(self):
"""Return the state of the generic device."""
if (hasattr(self._device, 'sabotage') and
self._device.sabotage == HMIP_SABOTAGE):
return STATE_SABOTAGE
elif self._device.lowBat:
return STATE_LOW_BATTERY
elif self._device.updateState.lower() != HMIP_UPTODATE:
return self._device.updateState.lower()
return STATE_OK
class HomematicipHeatingThermostat(HomematicipGenericDevice):
"""MomematicIP heating thermostat representation."""
@ -131,15 +96,19 @@ class HomematicipHeatingThermostat(HomematicipGenericDevice):
@property
def icon(self):
"""Return the icon."""
if self._device.valveState.lower() != HMIP_VALVE_DONE:
from homematicip.base.enums import ValveState
if self._device.valveState != ValveState.ADAPTION_DONE:
return 'mdi:alert'
return 'mdi:radiator'
@property
def state(self):
"""Return the state of the radiator valve."""
if self._device.valveState.lower() != HMIP_VALVE_DONE:
return self._device.valveState.lower()
from homematicip.base.enums import ValveState
if self._device.valveState != ValveState.ADAPTION_DONE:
return self._device.valveState
return round(self._device.valvePosition*100)
@property
@ -160,11 +129,6 @@ class HomematicipHumiditySensor(HomematicipGenericDevice):
"""Return the device class of the sensor."""
return DEVICE_CLASS_HUMIDITY
@property
def icon(self):
"""Return the icon."""
return 'mdi:water-percent'
@property
def state(self):
"""Return the state."""
@ -188,11 +152,6 @@ class HomematicipTemperatureSensor(HomematicipGenericDevice):
"""Return the device class of the sensor."""
return DEVICE_CLASS_TEMPERATURE
@property
def icon(self):
"""Return the icon."""
return 'mdi:thermometer'
@property
def state(self):
"""Return the state."""

View File

@ -421,7 +421,7 @@ home-assistant-frontend==20180713.0
# homekit==0.6
# homeassistant.components.homematicip_cloud
homematicip==0.9.6
homematicip==0.9.8
# homeassistant.components.google
# homeassistant.components.remember_the_milk

View File

@ -84,7 +84,7 @@ holidays==0.9.5
home-assistant-frontend==20180713.0
# homeassistant.components.homematicip_cloud
homematicip==0.9.6
homematicip==0.9.8
# homeassistant.components.influxdb
# homeassistant.components.sensor.influxdb