From db8313e0d5d387d6d0b80ef60e05a2b3391c9b7f Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Tue, 16 Oct 2018 20:45:24 +0200 Subject: [PATCH] Fix config dump time output (#184) --- esphomeyaml/core.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/esphomeyaml/core.py b/esphomeyaml/core.py index 3b3722724a..e59159471a 100644 --- a/esphomeyaml/core.py +++ b/esphomeyaml/core.py @@ -113,6 +113,21 @@ class TimePeriod(object): out['days'] = self.days return out + def __str__(self): + if self.microseconds is not None: + return '{} us'.format(self.total_microseconds) + if self.milliseconds is not None: + return '{} ms'.format(self.total_milliseconds) + if self.seconds is not None: + return '{} s'.format(self.total_seconds) + if self.minutes is not None: + return '{} min'.format(self.total_minutes) + if self.hours is not None: + return '{} h'.format(self.total_hours) + if self.days is not None: + return '{} d'.format(self.total_days) + return '0' + @property def total_microseconds(self): return self.total_milliseconds * 1000 + (self.microseconds or 0)