Skip to content

Commit

Permalink
Fix #236: Always use battery percentage if available
Browse files Browse the repository at this point in the history
  • Loading branch information
sebr committed Apr 23, 2024
1 parent 97c1195 commit aaa1c69
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion custom_components/bhyve/sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Support for Orbit BHyve sensors."""

import logging
from datetime import timedelta

Expand Down Expand Up @@ -173,7 +174,7 @@ def parse_battery_level(battery_data):
float: The battery level as a percentage.
"""
battery_level = battery_data.get("percent", 0)
if "mv" in battery_data:
if "mv" in battery_data and "percent" not in battery_data:
battery_level = min(battery_data.get("mv", 0) / 3000 * 100, 100)
return battery_level

Expand Down

0 comments on commit aaa1c69

Please sign in to comment.