Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: Added new sensors #7

Merged
merged 6 commits into from
Mar 6, 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
45 changes: 45 additions & 0 deletions custom_components/audiconnect/audi_connect_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,15 @@ async def update_vehicle_charger(self):
self._vehicle.state["plugState"] = get_attr(
result, "charger.status.plugStatusData.plugState.content"
)
self._vehicle.state["plugLockState"] = get_attr(
result, "charger.status.plugStatusData.plugLockState.content"
)
self._vehicle.state["externalPower"] = get_attr(
result, "charger.status.plugStatusData.externalPower.content"
)
self._vehicle.state["plugledColor"] = get_attr(
result, "charger.status.plugStatusData.plugledColor.content"
)

except TimeoutError:
raise
Expand Down Expand Up @@ -1379,6 +1388,42 @@ def plug_state_supported(self):
if check:
return True

@property
def plug_lock_state(self):
"""Return plug lock state"""
if self.plug_lock_state_supported:
return self._vehicle.state.get("plugLockState")

@property
def plug_lock_state_supported(self):
check = self._vehicle.state.get("plugLockState")
if check:
return True

@property
def external_power(self):
"""Return external Power"""
if self.external_power_supported:
return self._vehicle.state.get("externalPower")

@property
def external_power_supported(self):
check = self._vehicle.state.get("externalPower")
if check:
return True

@property
def plug_led_color(self):
"""Return plug LED Color"""
if self.plug_led_color_supported:
return self._vehicle.state.get("plugledColor")

@property
def plug_led_color_supported(self):
check = self._vehicle.state.get("plugledColor")
if check:
return True

@property
def climatisation_state(self):
if self.climatisation_state_supported:
Expand Down
5 changes: 4 additions & 1 deletion custom_components/audiconnect/audi_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ def __init__(self, data):
self._tryAppendStateWithTs(data, "chargeMode", -1, ["charging", "chargingStatus", "value", "chargeMode"])
self._tryAppendStateWithTs(data, "chargingState", -1, ["charging", "chargingStatus", "value", "chargingState"])
self._tryAppendStateWithTs(data, "plugState", -1, ["charging", "plugStatus", "value", "plugConnectionState"])
self._tryAppendStateWithTs(data, "remainingChargingTime", -1, ["charging", "plugStatus", "value", "remainingChargingTimeToComplete_min"])
self._tryAppendStateWithTs(data, "remainingChargingTime", -1, ["charging", "chargingStatus", "value", "remainingChargingTimeToComplete_min"])
self._tryAppendStateWithTs(data, "plugLockState", -1, ["charging", "plugStatus", "value", "plugLockState"])
self._tryAppendStateWithTs(data, "externalPower", -1, ["charging", "plugStatus", "value", "externalPower"])
self._tryAppendStateWithTs(data, "plugledColor", -1, ["charging", "plugStatus", "value", "ledColor"])

self._tryAppendStateWithTs(data, "climatisationState", -1, ["climatisation", "auxiliaryHeatingStatus", "value", "climatisationState"])

Expand Down
3 changes: 3 additions & 0 deletions custom_components/audiconnect/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,9 @@ def create_instruments():
unit=None,
),
Sensor(attr="plug_state", name="Plug state", icon="mdi:power-plug", unit=None),
Sensor(attr="plug_lock_state", name="Plug Lock state", icon="mdi:power-plug", unit=None),
Sensor(attr="external_power", name="External Power", icon="mdi:ev-station", unit=None),
Sensor(attr="plug_led_color", name="Plug LED Color", icon="mdi:power-plug", unit=None),
Sensor(
attr="doors_trunk_status",
name="Doors/trunk state",
Expand Down
Loading