8000 Use icon_for_battery_level() to set Ring battery level by tchellomello · Pull Request #9594 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use icon_for_battery_level() to set Ring battery level #9594

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
Oct 6, 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
4 changes: 4 additions & 0 deletions homeassistant/components/sensor/ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
CONF_ENTITY_NAMESPACE, CONF_MONITORED_CONDITIONS,
STATE_UNKNOWN, ATTR_ATTRIBUTION)
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.icon import icon_for_battery_level

DEPENDENCIES = ['ring']

Expand Down Expand Up @@ -108,6 +109,9 @@ def device_state_attributes(self):
@property
def icon(self):
"""Icon to use in the frontend, if any."""
if self._sensor_type == 'battery' and self._state is not STATE_UNKNOWN:
return icon_for_battery_level(battery_level=int(self._state),
charging=False)
return self._icon

@property
Expand Down
0