Added egg age to the eggminder sensor (#20758)

* Added egg age to the eggminder sensor
This commit is contained in:
William Scanlon 2019-02-05 21:26:54 -05:00 committed by GitHub
parent 3bb5caabe2
commit d13b2ca6ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,6 @@ import logging
from homeassistant.components.wink import DOMAIN, WinkDevice
from homeassistant.const import TEMP_CELSIUS
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__)
@ -47,7 +46,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
_LOGGER.info("Device is not a sensor")
class WinkSensorDevice(WinkDevice, Entity):
class WinkSensorDevice(WinkDevice):
"""Representation of a Wink sensor."""
def __init__(self, wink, hass):
@ -87,3 +86,15 @@ class WinkSensorDevice(WinkDevice, Entity):
def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement
@property
def device_state_attributes(self):
"""Return the state attributes."""
super_attrs = super().device_state_attributes
_LOGGER.debug("Adding in eggs if egg minder")
try:
super_attrs['egg_times'] = self.wink.eggs()
_LOGGER.debug("Its an egg minder")
except AttributeError:
_LOGGER.debug("Not an eggtray")
return super_attrs