Skip to content

Commit

Permalink
Default battery voltages if none stored in config.
Browse files Browse the repository at this point in the history
Default the values, otherwise 'None' gets passed to the calculation later on and the battery % is returned as unknown.

I also note that in Surrey the voltages are 1.6 and 1.2, whilst in sure has the voltages are 1.6 and 1.25. Not sure is that is intentional.
  • Loading branch information
RogerSelwyn committed Sep 16, 2021
1 parent 823f58c commit 23e7ddb
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@

# pylint: disable=relative-beyond-top-level
from . import SurePetcareAPI
from .const import ATTR_VOLTAGE_FULL, ATTR_VOLTAGE_LOW, DOMAIN, SPC, SURE_MANUFACTURER
from .const import (
ATTR_VOLTAGE_FULL,
ATTR_VOLTAGE_LOW,
DOMAIN,
SPC,
SURE_BATT_VOLTAGE_FULL,
SURE_BATT_VOLTAGE_LOW,
SURE_MANUFACTURER,
)

PARALLEL_UPDATES = 2

Expand Down Expand Up @@ -77,12 +85,8 @@ async def async_setup_entry(
EntityType.FELAQUA,
]:

voltage_batteries_full = cast(
float, config_entry.options.get(ATTR_VOLTAGE_FULL)
)
voltage_batteries_low = cast(
float, config_entry.options.get(ATTR_VOLTAGE_LOW)
)
voltage_batteries_full = cast(float, config_entry.options.get(ATTR_VOLTAGE_FULL, SURE_BATT_VOLTAGE_FULL))
voltage_batteries_low = cast(float, config_entry.options.get(ATTR_VOLTAGE_LOW, SURE_BATT_VOLTAGE_LOW))

entities.append(
Battery(
Expand Down

0 comments on commit 23e7ddb

Please sign in to comment.