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

Updated code to new vacuum state property #162

Merged
merged 1 commit into from
Jan 10, 2025
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
56 changes: 24 additions & 32 deletions custom_components/wellbeing/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@
import logging
import math

from homeassistant.components.vacuum import StateVacuumEntity, VacuumEntityFeature
from homeassistant.components.vacuum import (
STATE_CLEANING,
STATE_PAUSED,
STATE_RETURNING,
STATE_IDLE,
STATE_DOCKED,
STATE_ERROR,
)
from homeassistant.components.vacuum import StateVacuumEntity, VacuumActivity, VacuumEntityFeature
from homeassistant.const import Platform
from homeassistant.util.percentage import ranged_value_to_percentage

Expand All @@ -31,26 +23,26 @@
| VacuumEntityFeature.BATTERY
)

VACUUM_STATES = {
1: STATE_CLEANING, # Regular Cleaning
2: STATE_PAUSED,
3: STATE_CLEANING, # Stop cleaning
4: STATE_PAUSED, # Pause Spot cleaning
5: STATE_RETURNING,
6: STATE_PAUSED, # Paused returning
7: STATE_RETURNING, # Returning for pitstop
8: STATE_PAUSED, # Paused returning for pitstop
9: STATE_DOCKED, # Charging
10: STATE_IDLE,
11: STATE_ERROR,
12: STATE_DOCKED, # Pitstop
13: STATE_IDLE, # Manual stearing
14: STATE_IDLE, # Firmware upgrading
"idle": STATE_IDLE, # robot700series idle
"inProgress": STATE_CLEANING, # robot700series cleaning
"goingHome": STATE_RETURNING, # robot700series returning
"paused": STATE_PAUSED, # robot700series paused
"sleeping": STATE_DOCKED, # robot700series sleeping
VACUUM_ACTIVITIES = {
1: VacuumActivity.CLEANING, # Regular Cleaning
2: VacuumActivity.PAUSED,
3: VacuumActivity.CLEANING, # Stop cleaning
4: VacuumActivity.PAUSED, # Pause Spot cleaning
5: VacuumActivity.RETURNING,
6: VacuumActivity.PAUSED, # Paused returning
7: VacuumActivity.RETURNING, # Returning for pitstop
8: VacuumActivity.PAUSED, # Paused returning for pitstop
9: VacuumActivity.DOCKED, # Charging
10: VacuumActivity.IDLE,
11: VacuumActivity.ERROR,
12: VacuumActivity.DOCKED, # Pitstop
13: VacuumActivity.IDLE, # Manual stearing
14: VacuumActivity.IDLE, # Firmware upgrading
"idle": VacuumActivity.IDLE, # robot700series idle
"inProgress": VacuumActivity.CLEANING, # robot700series cleaning
"goingHome": VacuumActivity.RETURNING, # robot700series returning
"paused": VacuumActivity.PAUSED, # robot700series paused
"sleeping": VacuumActivity.DOCKED, # robot700series sleeping
}

VACUUM_CHARGING_STATES = [9, 'idle']
Expand Down Expand Up @@ -98,9 +90,9 @@ def supported_features(self) -> int:
return SUPPORTED_FEATURES

@property
def state(self):
"""Return the state of the vacuum."""
return VACUUM_STATES.get(self.get_entity.state, STATE_ERROR)
def activity(self):
"""Return the current vacuum activity."""
return VACUUM_ACTIVITIES.get(self.get_entity.state, VacuumActivity.ERROR)

@property
def battery_level(self):
Expand Down
Loading