Skip to content

Commit

Permalink
Support for 700 series Robot Vacuum (#152)
Browse files Browse the repository at this point in the history
* add Electrolux Vacuum Robots 700series support

* small fix

* add Vacuum Robots to README

* remove unecessary log

* fix: use unit PERCENTAGE for 700series battery
  • Loading branch information
ivancoppa authored Oct 27, 2024
1 parent c56b3b7 commit e775207
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 6 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ A custom component designed for [Home Assistant](https://www.home-assistant.io)
- EHAW4010AG
- EHAW6020AG

- Electrolux PUREi9 Vacuum Robot
- PUREi9
- PUREi9.2

- Electrolux PUREi9 Vacuum Robot
- PUREi9
- PUREi9.2

- Electrolux 600/700 Series Vacuum Robot
- Clean 600
- Hygienic 600
- Hygienic 700
- Ultimate 700

- AEG AX5 Air Purifiers
- AX51-304WT

Expand All @@ -41,6 +55,15 @@ A custom component designed for [Home Assistant](https://www.home-assistant.io)
- AX91-604GY
- AX91-604DG

- AEG RX9 Vacuum Robot
- RX9
- RX9.2

- AEG 6000/7000 Series Vacuum Robot
- 6000 Robot Vacuum Cleaner
- 7000 Robot Vacuum Cleaner


### Install with HACS (recommended)

Do you you have [HACS][hacs] installed? Just search for Electrolux Wellbeing and install it direct from HACS. HACS will keep track of updates and you can easily upgrade this integration to latest version.
Expand Down
43 changes: 41 additions & 2 deletions custom_components/wellbeing/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Model(str, Enum):
AX7 = "AX7"
AX9 = "AX9"
PUREi9 = "PUREi9"
Robot700series = "700series" # 700series vacuum robot series


class WorkMode(str, Enum):
Expand Down Expand Up @@ -217,6 +218,35 @@ def _create_entities(data):
),
]

Robot700series_entities = [
ApplianceVacuum(
name="Robot Status",
attr="state"
),
ApplianceSensor(
name="Cleaning Mode",
attr="cleaningMode",
device_class=SensorDeviceClass.ENUM,
),
ApplianceSensor(
name="Water Pump Rate",
attr="waterPumpRate",
device_class=SensorDeviceClass.ENUM,
),
ApplianceSensor(
name="Battery Status",
attr="batteryStatus",
unit=PERCENTAGE,
device_class=SensorDeviceClass.BATTERY,
),
ApplianceSensor(
name="Charging Status",
attr="chargingStatus",
device_class=SensorDeviceClass.ENUM,
),
ApplianceBinary(name="Mop Installed", attr="mopInstalled"),
]

common_entities = [
ApplianceFan(
name="Fan Speed",
Expand Down Expand Up @@ -298,6 +328,7 @@ def _create_entities(data):
+ a7_entities
+ pure500_entities
+ purei9_entities
+ Robot700series_entities
)

def get_entity(self, entity_type, entity_attr):
Expand Down Expand Up @@ -435,23 +466,31 @@ async def async_get_appliances(self) -> Appliances:
return Appliances(found_appliances)

async def command_vacuum(self, pnc_id: str, cmd: str):
data = {"CleaningCommand": cmd}
appliance = self._api_appliances.get(pnc_id, None)
if appliance is None:
_LOGGER.error(
f"Failed to send vacuum command for appliance with id {pnc_id}"
)
return

data = {}
match Model(appliance.type):
case Model.Robot700series.value:
data = {"cleaningCommand": cmd}
case Model.PUREi9.value:
data = {"CleaningCommand": cmd}

result = await appliance.send_command(data)
_LOGGER.debug(f"Vacuum command: {result}")

async def set_vacuum_power_mode(self, pnc_id: str, mode: int):
data = {
"powerMode": mode
} # Not the right formatting. Disable FAN_SPEEDS until this is figured out

appliance = self._api_appliances.get(pnc_id, None)
if appliance is None:
_LOGGER.error(f"Failed to set feature {feature} for appliance with id {pnc_id}")
_LOGGER.error(f"Failed to set feature Power Mode to {mode} for appliance with id {pnc_id}")
return
result = await appliance.send_command(data)
_LOGGER.debug(f"Set Vacuum Power Mode: {result}")
Expand Down
40 changes: 36 additions & 4 deletions custom_components/wellbeing/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from . import WellbeingDataUpdateCoordinator
from .const import DOMAIN
from .entity import WellbeingEntity
from .api import Model

_LOGGER: logging.Logger = logging.getLogger(__package__)

Expand All @@ -45,6 +46,11 @@
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_CHARGING_STATE = 9 # For selecting battery icon
Expand Down Expand Up @@ -81,6 +87,7 @@ def __init__(
):
super().__init__(coordinator, config_entry, pnc_id, entity_type, entity_attr)
self._fan_speeds = self.get_appliance.vacuum_fan_speeds
self.entity_model = self.get_appliance.model

@property
def _battery_range(self) -> tuple[int, int]:
Expand Down Expand Up @@ -132,16 +139,41 @@ def fan_speed_list(self):
return list(self._fan_speeds.values())

async def async_start(self):
await self.api.command_vacuum(self.pnc_id, "play")
command=""
match self.entity_model:
case Model.PUREi9.value:
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):
await self.api.command_vacuum(self.pnc_id, "stop")
command=""
match self.entity_model:
case Model.PUREi9.value:
command="stop"
case Model.Robot700series.value:
command="stopClean"
await self.api.command_vacuum(self.pnc_id, command)

async def async_pause(self):
await self.api.command_vacuum(self.pnc_id, "pause")
command=""
match self.entity_model:
case Model.PUREi9.value:
command="pause"
case Model.Robot700series.value:
command="pauseClean"
await self.api.command_vacuum(self.pnc_id, command)

async def async_return_to_base(self):
await self.api.command_vacuum(self.pnc_id, "home")
command=""
match self.entity_model:
case Model.PUREi9.value:
command="home"
case Model.Robot700series.value:
command="startGoToCharger"
await self.api.command_vacuum(self.pnc_id, command)

async def async_set_fan_speed(self, fan_speed: str):
"""Set the fan speed of the vacuum cleaner."""
Expand Down

0 comments on commit e775207

Please sign in to comment.