Skip to content

Commit

Permalink
fix: Door trunk state (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolbi authored Nov 7, 2024
1 parent a4ee572 commit 20bc75a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
44 changes: 26 additions & 18 deletions custom_components/audiconnect/audi_connect_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -1437,27 +1437,35 @@ def right_rear_door_open(self):

@property
def doors_trunk_status_supported(self):
return (
self.any_door_open_supported
and self.any_door_unlocked_supported
and self.trunk_open_supported
and self.trunk_unlocked_supported
)
checkLeftFront = self._vehicle.fields.get("OPEN_STATE_LEFT_FRONT_DOOR")
checkLeftRear = self._vehicle.fields.get("OPEN_STATE_LEFT_REAR_DOOR")
checkRightFront = self._vehicle.fields.get("OPEN_STATE_RIGHT_FRONT_DOOR")
checkRightRear = self._vehicle.fields.get("OPEN_STATE_RIGHT_REAR_DOOR")
checkTrunk = self._vehicle.fields.get("OPEN_STATE_TRUNK_LID")
if (
checkLeftFront
and checkLeftRear
and checkRightFront
and checkRightRear
and checkTrunk
):
return True

@property
def doors_trunk_status(self):
if (
self.any_door_open_supported
and self.any_door_unlocked_supported
and self.trunk_open_supported
and self.trunk_unlocked_supported
):
if self.any_door_open or self.trunk_open:
return "Open"
elif self.any_door_unlocked or self.trunk_unlocked:
return "Closed"
else:
return "Locked"
if self.doors_trunk_status_supported:
checkLeftFront = self._vehicle.fields.get("OPEN_STATE_LEFT_FRONT_DOOR")
checkLeftRear = self._vehicle.fields.get("OPEN_STATE_LEFT_REAR_DOOR")
checkRightFront = self._vehicle.fields.get("OPEN_STATE_RIGHT_FRONT_DOOR")
checkRightRear = self._vehicle.fields.get("OPEN_STATE_RIGHT_REAR_DOOR")
checkTrunk = self._vehicle.fields.get("OPEN_STATE_TRUNK_LID")
return not (
checkLeftFront == "3"
and checkLeftRear == "3"
and checkRightFront == "3"
and checkRightRear == "3"
and checkTrunk == "3"
)

@property
def trunk_unlocked(self):
Expand Down
4 changes: 2 additions & 2 deletions custom_components/audiconnect/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,10 @@ def create_instruments():
icon="mdi:ev-plug-type1",
entity_category=EntityCategory.DIAGNOSTIC,
),
Sensor(
BinarySensor(
attr="doors_trunk_status",
name="Doors/trunk state",
icon="mdi:car-door",
device_class=BinarySensorDeviceClass.DOOR,
),
Sensor(
attr="climatisation_state",
Expand Down

0 comments on commit 20bc75a

Please sign in to comment.