mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Back to you travis....
This commit is contained in:
parent
a718e92708
commit
b163544e3c
@ -146,55 +146,58 @@ class WemoSwitch(SwitchDevice):
|
|||||||
if self.insight_params:
|
if self.insight_params:
|
||||||
try:
|
try:
|
||||||
return self._current_power_mw() / 1000
|
return self._current_power_mw() / 1000
|
||||||
except:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def power_threshold(self):
|
def power_threshold(self):
|
||||||
|
"""Threshold of W at which Insight will indicate it's load is ON."""
|
||||||
if self.insight_params:
|
if self.insight_params:
|
||||||
return self.insight_params['powerthreshold'] / 1000
|
return self.insight_params['powerthreshold'] / 1000
|
||||||
|
|
||||||
def _as_uptime(self, _seconds):
|
@staticmethod
|
||||||
d = datetime(1,1,1) + timedelta(seconds=_seconds)
|
def as_uptime(_seconds):
|
||||||
return "{:0>2d}d {:0>2d}h {:0>2d}m {:0>2d}s".format(d.day-1,
|
"""Format seconds in to uptime string in the format: 00d 00h 00m 00s """
|
||||||
d.hour,
|
uptime = datetime(1, 1, 1) + timedelta(seconds=_seconds)
|
||||||
d.minute,
|
return "{:0>2d}d {:0>2d}h {:0>2d}m {:0>2d}s".format(uptime.day-1,
|
||||||
d.second)
|
uptime.hour,
|
||||||
|
uptime.minute,
|
||||||
|
uptime.second)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def on_for(self):
|
def on_for(self):
|
||||||
"""On time in seconds."""
|
"""On time in seconds."""
|
||||||
if self.insight_params:
|
if self.insight_params:
|
||||||
return self._as_uptime(self.insight_params['onfor'])
|
return as_uptime(self.insight_params['onfor'])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def on_today(self):
|
def on_today(self):
|
||||||
"""On time in seconds."""
|
"""On time in seconds."""
|
||||||
if self.insight_params:
|
if self.insight_params:
|
||||||
return self._as_uptime(self.insight_params['ontoday'])
|
return as_uptime(self.insight_params['ontoday'])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def on_total(self):
|
def on_total(self):
|
||||||
"""On time in seconds."""
|
"""On time in seconds."""
|
||||||
if self.insight_params:
|
if self.insight_params:
|
||||||
return self._as_uptime(self.insight_params['ontotal'])
|
return as_uptime(self.insight_params['ontotal'])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def power_total_mw_min(self):
|
def power_total_mw_min(self):
|
||||||
"""This is a total of average mW per minute."""
|
"""Total of average mW per minute."""
|
||||||
if self.insight_params:
|
if self.insight_params:
|
||||||
try:
|
try:
|
||||||
return self.insight_params['totalmw']
|
return self.insight_params['totalmw']
|
||||||
except:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def power_today_mw_min(self):
|
def power_today_mw_min(self):
|
||||||
"""This is the total consumption today in mW per minute."""
|
"""Total consumption today in mW per minute."""
|
||||||
if self.insight_params:
|
if self.insight_params:
|
||||||
try:
|
try:
|
||||||
return self.insight_params['todaymw']
|
return self.insight_params['todaymw']
|
||||||
except:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user