Skip to content
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

Fix vacuum battery reporting for PUREi9 and 700series #153

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
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
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
Loading