Skip to content

Commit

Permalink
Fix vacuum battery reporting for PUREi9 and 700series (#153)
Browse files Browse the repository at this point in the history
* fix vacuum battery reporting for PUREi9 and 700series

* fix battery range minimum for 700series
  • Loading branch information
ivancoppa authored Oct 28, 2024
1 parent 80e7e08 commit dc3a440
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
14 changes: 5 additions & 9 deletions custom_components/wellbeing/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,6 @@ def _create_entities(data):
attr="waterPumpRate",
device_class=SensorDeviceClass.ENUM,
),
ApplianceSensor(
name="Battery Status",
attr="batteryStatus",
unit=PERCENTAGE,
device_class=SensorDeviceClass.BATTERY,
),
ApplianceSensor(
name="Charging Status",
attr="chargingStatus",
Expand Down Expand Up @@ -396,9 +390,11 @@ def speed_range(self) -> tuple[int, int]:

@property
def battery_range(self) -> tuple[int, int]:
if self.model == Model.PUREi9:
return 2, 6 # Do not include lowest value of 1 to make this mean empty (0%) battery

match Model(self.model):
case Model.Robot700series.value:
return 1, 100
case Model.PUREi9.value:
return 2, 6 # Do not include lowest value of 1 to make this mean empty (0%) battery
return 0, 0

@property
Expand Down
8 changes: 5 additions & 3 deletions custom_components/wellbeing/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"sleeping": STATE_DOCKED, # robot700series sleeping
}

VACUUM_CHARGING_STATE = 9 # For selecting battery icon
VACUUM_CHARGING_STATES = [9, 'idle']


async def async_setup_entry(hass, entry, async_add_devices):
Expand Down Expand Up @@ -111,8 +111,11 @@ def battery_level(self):
def battery_icon(self):
"""Return the battery icon of the vacuum based on the battery level."""
level = self.battery_level
charging = self.get_entity.state == VACUUM_CHARGING_STATE

charging = self.get_entity.state in VACUUM_CHARGING_STATES

level = 10*round(level / 10) # Round level to nearest 10 for icon selection

# Special cases given available icons
if level == 100 and charging:
return "mdi:battery-charging-100"
Expand Down Expand Up @@ -145,7 +148,6 @@ async def async_start(self):
command="play"
case Model.Robot700series.value:
command="startGlobalClean"
_LOGGER.warning(f"VACUUM async_start {self.entity_type} {self.entity_attr} {command}")
await self.api.command_vacuum(self.pnc_id, command)

async def async_stop(self):
Expand Down

0 comments on commit dc3a440

Please sign in to comment.