8000 Tellduslive: Accurate implementation of battery level by molobrakos · Pull Request #10788 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Tellduslive: Accurate implementation of battery level #10788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions homeassistant/components/tellduslive.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,17 @@ def device_state_attributes(self):
@property
def _battery_level(self):
"""Return the battery level of a device."""
return round(self.device.battery * 100 / 255) \
if self.device.battery else None
from tellduslive import (BATTERY_LOW,
BATTERY_UNKNOWN,
BATTERY_OK)
if self.device.battery == BATTERY_LOW:
return 1
elif self.device.battery == BATTERY_UNKNOWN:
return None
elif self.device.battery == BATTERY_OK:
return 100
else:
return self.device.battery # Percentage

@property
def _last_updated(self):
Expand Down
0