Skip to content

Commit

Permalink
Add manual for the integration. Update dustbin states. (#36)
Browse files Browse the repository at this point in the history
* Add a manual

* fix

* fix

* create an internal representation of dustbin states

* no need for upper dustbin anymore

* convert the dustbin values

* home assistant does not understand match
  • Loading branch information
Ekman committed Dec 4, 2021
1 parent 750a9a8 commit 065a746
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 3 deletions.
39 changes: 39 additions & 0 deletions MANUAL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Manual

The integration supports the basic commands: start, stop, pause and return to dock. Additionally, you can set fan speed
and view the dustbin status. This integration is not clever and does not try to implement features of its own, it simply
passes data back and forth to the Pure i9 API.

## Fan speed

For older vacuums there's two fan speeds and for newer three.

### Pure i9.2

For the newer models the name of the fan speeds are:

| Name |
| --- |
| QUIET |
| SMART |
| POWER |

### Pure i9

For the older models the name of the fan speeds are:

| Name |
| --- |
| ECO |
| POWER |

## Dustbin

You can read the dustbin status of the vacuum using the attribute `dustbin`. The values of the dustbin can be:

| Name | Description |
| --- | --- |
| UNKNOWN | No information available |
| CONNECTED | The vacuum is ready to be used |
| DISCONNECTED | There is no dustin connected |
| FULL | It's full and needs to be removed and emptied |
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Me or this repository is in no way affiliated with Electrolux. This is purely a

## Installation

Install using [Home Assistant Community Store (HACS)](https://hacs.xyz/).
Install using [Home Assistant Community Store (HACS)](https://hacs.xyz/).

**If you don't already have HACS installed** then follow these steps:

Expand All @@ -40,6 +40,8 @@ vacuum:
password: example
```
For more information on what the integration can do [read the manual](MANUAL.md).
## Versioning
This project complies with [Semantic Versioning](https://semver.org/).
Expand Down
21 changes: 21 additions & 0 deletions custom_components/purei9/purei9.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Pure i9 business logic"""
from typing import List
from enum import Enum
from purei9_unofficial.common import BatteryStatus, RobotStates, PowerMode, DustbinStates
from homeassistant.components.vacuum import (
STATE_CLEANING,
Expand Down Expand Up @@ -121,3 +122,23 @@ def fan_speed_to_hass(fan_speed_list: List[str], fan_speed_purei9: PowerMode) ->
return POWER_MODE_ECO

return POWER_MODE_POWER

class Dustbin(Enum):
"""Contains possible values for the dustbin"""
UNKNOWN = 1
CONNECTED = 2
DISCONNECTED = 3
FULL = 4

def dustbin_to_hass(dustbin: DustbinStates) -> Dustbin:
"""Conver the Pure i9 dustbin into an internal representation"""
if dustbin == DustbinStates.unset:
return Dustbin.UNKNOWN

if dustbin == DustbinStates.connected:
return Dustbin.CONNECTED

if dustbin == DustbinStates.empty:
return Dustbin.DISCONNECTED

return Dustbin.FULL
4 changes: 2 additions & 2 deletions custom_components/purei9/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def assumed_state(self) -> bool:

@property
def extra_state_attributes(self) -> Mapping[str, Any]:
return {"dustbin": self._params.dustbin.name.upper()}
return {"dustbin": self._params.dustbin.name}

def start(self) -> None:
"""Start cleaning"""
Expand Down Expand Up @@ -212,4 +212,4 @@ def update(self) -> None:
self._params.battery = purei9.battery_to_hass(pure_i9_battery)
self._params.available = self._robot.isconnected()
self._params.firmware = self._robot.getfirmware()
self._params.dustbin = purei9_dustbin
self._params.dustbin = purei9.dustbin_to_hass(purei9_dustbin)
13 changes: 13 additions & 0 deletions tests/test_purei9.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,18 @@ def test_fan_speed_to_hass(self):
with self.subTest():
self.assertEqual(expected, purei9.fan_speed_to_hass(fan_speed_list, fan_speed))

data_dustbin_to_hass = [
(DustbinStates.unset, purei9.Dustbin.UNKNOWN),
(DustbinStates.connected, purei9.Dustbin.CONNECTED),
(DustbinStates.empty, purei9.Dustbin.DISCONNECTED),
(DustbinStates.full, purei9.Dustbin.FULL),
]

def test_dustbin_to_hass(self):
"""Test to convert a dustbin value to internal format"""
for dustbin, expected in self.data_dustbin_to_hass:
with self.subTest():
self.assertEqual(expected, purei9.dustbin_to_hass(dustbin))

if __name__ == '__main__':
unittest.main()

0 comments on commit 065a746

Please sign in to comment.