Merge pull request #286 from rmkraus/entity_cleanup

Entity cleanup
pull/289/head
Paulus Schoutsen 2015-08-28 17:25:51 -07:00
commit 4b31a22a1c
3 changed files with 18 additions and 2 deletions

View File

@ -12,6 +12,7 @@ from datetime import timedelta
from homeassistant.loader import get_component
from homeassistant.helpers import validate_config
from homeassistant.helpers.entity import _OVERWRITE
import homeassistant.util as util
import homeassistant.util.dt as dt_util
@ -162,9 +163,12 @@ class DeviceTracker(object):
state = STATE_HOME if is_home else STATE_NOT_HOME
# overwrite properties that have been set in the config file
attr = dict(dev_info['state_attr'])
attr.update(_OVERWRITE.get(dev_info['entity_id'], {}))
self.hass.states.set(
dev_info['entity_id'], state,
dev_info['state_attr'])
dev_info['entity_id'], state, attr)
def update_devices(self, now):
""" Update device states based on the found devices. """

View File

@ -156,6 +156,12 @@ class ISYDeviceABC(ToggleEntity):
attr = {ATTR_FRIENDLY_NAME: self.name}
for name, prop in self._attrs.items():
attr[name] = getattr(self, prop)
attr = self._attr_filter(attr)
return attr
def _attr_filter(self, attr):
""" Placeholder for attribute filters. """
# pylint: disable=no-self-use
return attr
@property

View File

@ -38,3 +38,9 @@ class ISYLightDevice(ISYDeviceABC):
_attrs = {ATTR_BRIGHTNESS: 'value'}
_onattrs = [ATTR_BRIGHTNESS]
_states = [STATE_ON, STATE_OFF]
def _attr_filter(self, attr):
""" Filter brightness out of entity while off. """
if ATTR_BRIGHTNESS in attr and not self.is_on:
del attr[ATTR_BRIGHTNESS]
return attr