From d13b2ca6efff4e9584099a3a9ab5f915cfbe9733 Mon Sep 17 00:00:00 2001 From: William Scanlon Date: Tue, 5 Feb 2019 21:26:54 -0500 Subject: [PATCH] Added egg age to the eggminder sensor (#20758) * Added egg age to the eggminder sensor --- homeassistant/components/wink/sensor.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/wink/sensor.py b/homeassistant/components/wink/sensor.py index 8c2abc0f875..62f4638820f 100644 --- a/homeassistant/components/wink/sensor.py +++ b/homeassistant/components/wink/sensor.py @@ -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