From c20324793e7e59cc7b6c353fe573860cd818be54 Mon Sep 17 00:00:00 2001 From: Julio Guerra Date: Sun, 7 Jan 2018 22:37:19 +0100 Subject: [PATCH] timer: include the remaining time in the state attributes (#11510) Add the amount of remaining time before a timer is finished in its state attributes, so that it is received when fetching a timer state. In my particular case, it allows me to correctly implement a UI for a timer when it is paused and when the UI didn't received the pause state change (which happens when the UI is started after the pause). In this case, it is impossible to show the remaining amount of time before the timer ends. --- homeassistant/components/timer/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/homeassistant/components/timer/__init__.py b/homeassistant/components/timer/__init__.py index b2f5db88b5f..ec3429e0498 100644 --- a/homeassistant/components/timer/__init__.py +++ b/homeassistant/components/timer/__init__.py @@ -29,6 +29,7 @@ ENTITY_ID_FORMAT = DOMAIN + '.{}' DEFAULT_DURATION = 0 ATTR_DURATION = 'duration' +ATTR_REMAINING = 'remaining' CONF_DURATION = 'duration' STATUS_IDLE = 'idle' @@ -227,6 +228,7 @@ class Timer(Entity): """Return the state attributes.""" return { ATTR_DURATION: str(self._duration), + ATTR_REMAINING: str(self._remaining) } @asyncio.coroutine