Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

_LOGGER = logging.getLogger(__name__)

HMIP_OPEN = 'OPEN'
HMIP_ZONE_AWAY = 'EXTERNAL'
HMIP_ZONE_HOME = 'INTERNAL'

Expand Down Expand Up @@ -57,14 +56,18 @@ def __init__(self, home, device):
@property
def state(self):
"""Return the state of the device."""
from homematicip.base.enums import WindowState

if self._device.active:
if (self._device.sabotage or self._device.motionDetected or
self._device.windowState == HMIP_OPEN):
self._device.windowState == WindowState.OPEN):
return STATE_ALARM_TRIGGERED

if self._device.label == HMIP_ZONE_HOME:
active = self._home.get_security_zones_activation()
if active == (True, True):
return STATE_ALARM_ARMED_AWAY
elif active == (False, True):
return STATE_ALARM_ARMED_HOME
return STATE_ALARM_ARMED_AWAY

return STATE_ALARM_DISARMED

Expand All @@ -79,10 +82,3 @@ async def async_alarm_arm_home(self, code=None):
async def async_alarm_arm_away(self, code=None):
"""Send arm away command."""
await self._home.set_security_zones_activation(True, True)

@property
def device_state_attributes(self):
"""Return the state attributes of the alarm control device."""
# The base class is loading the battery property, but device doesn't
# have this property - base class needs clean-up.
return None
19 changes: 15 additions & 4 deletions homeassistant/components/homematicip_cloud/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,21 @@ def available(self):
"""Device available."""
return not self._device.unreach

@property
def icon(self):
"""Return the icon."""
if hasattr(self._device, 'lowBat') and self._device.lowBat:
return 'mdi:battery-outline'
if hasattr(self._device, 'sabotage') and self._device.sabotage:
return 'mdi:alert'
return None

@property
def device_state_attributes(self):
"""Return the state attributes of the generic device."""
return {
ATTR_LOW_BATTERY: self._device.lowBat,
ATTR_MODEL_TYPE: self._device.modelType
}
attr = {ATTR_MODEL_TYPE: self._device.modelType}
if hasattr(self._device, 'lowBat') and self._device.lowBat:
attr.update({ATTR_LOW_BATTERY: self._device.lowBat})
if hasattr(self._device, 'sabotage') and self._device.sabotage:
attr.update({ATTR_SABOTAGE: self._device.sabotage})
return attr
7 changes: 2 additions & 5 deletions homeassistant/components/sensor/homematicip_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ 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 HomematicipHeatingThermostat(HomematicipGenericDevice):
"""MomematicIP heating thermostat representation."""
Expand All @@ -98,6 +93,8 @@ def icon(self):
"""Return the icon."""
from homematicip.base.enums import ValveState

if super().icon:
return super().icon
if self._device.valveState != ValveState.ADAPTION_DONE:
return 'mdi:alert'
return 'mdi:radiator'
Expand Down