Skip to content

Commit

Permalink
feat: add "Wiper Health" sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
philippwaller committed Oct 3, 2024
1 parent 3a66ec4 commit 9225fbf
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ Depends on your own car or purchased Mercedes Benz licenses.
precondState, precondActive, precondError, precondNow, precondNowError, precondDuration, precondatdeparture, precondAtDepartureDisable, precondSeatFrontLeft, precondSeatFrontRight, precondSeatRearLeft, precondSeatRearRight
```

- wiperHealth

```
attributes:
wiperLifetimeExceeded [EXPERIMENTAL, user feedback wanted]
```

### Device Tracker

```
Expand Down
8 changes: 8 additions & 0 deletions custom_components/mbapi2020/car.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@
"auxheattime3",
]

WIPER_OPTIONS = ["wiperLifetimeExceeded", "wiperHealthPercent"]

PRE_COND_OPTIONS = [
"precondStatus",
"precondOperatingMode",
Expand Down Expand Up @@ -224,6 +226,7 @@ def __init__(self, vin: str):

self.binarysensors = None
self.tires = None
self.wipers = None
self.odometer = None
self.doors = None
self.location = None
Expand Down Expand Up @@ -295,6 +298,11 @@ class Tires:

name: str = "Tires"

@dataclass(init=False)
class Wipers:
"""Stores the Wiper values at runtime."""

name: str = "Wipers"

@dataclass(init=False)
class Odometer:
Expand Down
10 changes: 10 additions & 0 deletions custom_components/mbapi2020/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
PRE_COND_OPTIONS,
TIRE_OPTIONS,
WINDOW_OPTIONS,
WIPER_OPTIONS,
Auxheat,
BinarySensors,
Car,
Expand All @@ -44,6 +45,7 @@
Precond,
Tires,
Windows,
Wipers,
)
from .const import (
CONF_DEBUG_FILE_SAVE,
Expand Down Expand Up @@ -303,6 +305,14 @@ def _build_car(self, received_car_data, update_mode):
update_mode,
)

car.wipers = self._get_car_values(
received_car_data,
car.finorvin,
Wipers() if not car.wipers else car.wipers,
WIPER_OPTIONS,
update_mode,
)

car.doors = self._get_car_values(
received_car_data,
car.finorvin,
Expand Down
17 changes: 17 additions & 0 deletions custom_components/mbapi2020/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,23 @@
None,
None,
],
"wiperHealthPercent": [
"Wiper Health",
None, # Deprecated: DO NOT USE
"wipers",
"wiperHealthPercent",
"value",
None,
{
"wiperLifetimeExceeded",
},
"mdi:wiper",
None,
False,
None,
None,
None,
],
}

LOCKS = {
Expand Down

0 comments on commit 9225fbf

Please # to comment.