Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add new sensor "Wiper Health" #265

Merged
merged 1 commit into from
Oct 3, 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
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
Loading