Repository: bimmerconnected/bimmer_connected
Pull request #517 (2023-02-11 19:09:36)

Make new attributes available for HA
<!--
  Thanks for your contribution to bimmer_connected!
-->
## Breaking change
<!--
  If your PR contains a breaking change, please explain that change here.
  Note: Remove this section if this PR is NOT a breaking change.
-->


## Proposed change
<!--
  Describe the big picture of your changes here to communicate to the
  maintainers why we should accept this pull request. If it fixes a bug
  or resolves a feature request, be sure to link to that issue in the
  additional information section.
-->
Make the atrributes from #516 available for HA:
* `charging target`
* `charging limit`
 
also added:
* `charging mode`
* `charging preference`
* `charging_start_time` which is already part of `sensor.py` in HA but isn't available without this change
* `is_pre_entry_climatization_enabled`

## Type of change
- [ ] Bugfix (non-breaking change which fixes an issue)
- [x] New feature (which adds functionality to this library)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests

## Additional information
<!--
  Details are important, and help maintainers processing your PR.
  Please be sure to fill out additional details, if applicable.
-->

- This PR fixes or closes issue: fixes #
- This PR is related to issue: 

## Checklist
<!--
  Put an `x` in the boxes that apply. You can also fill these out after
  creating the PR. If you're unsure about any of them, don't hesitate to ask.
  We're here to help! This is simply a reminder of what we are going to look
  for before merging your code.
-->

- [x] The code change is tested and works locally.
- [x] Tests have been added to verify that the new code works.



Patch:
diff --git a/bimmer_connected/vehicle/vehicle.py b/bimmer_connected/vehicle/vehicle.py
index 2405ffe..e13d809 100644
--- a/bimmer_connected/vehicle/vehicle.py
+++ b/bimmer_connected/vehicle/vehicle.py
@@ -224,6 +224,7 @@ class MyBMWVehicle:
         if self.has_electric_drivetrain:
             result += [
                 "charging_time_remaining",
+                "charging_start_time",
                 "charging_end_time",
                 "charging_time_label",
                 "charging_status",
@@ -231,6 +232,11 @@ class MyBMWVehicle:
                 "remaining_battery_percent",
                 "remaining_range_electric",
                 "last_charging_end_result",
+                "ac_current_limit",
+                "charging_target",
+                "charging_mode",
+                "charging_preferences",
+                "is_pre_entry_climatization_enabled",
             ]
         if self.has_combustion_drivetrain:
             result += ["remaining_fuel", "remaining_range_fuel", "remaining_fuel_percent"]


Test patch:
diff --git a/test/test_vehicle.py b/test/test_vehicle.py
index bcb47bc..5fb195c 100644
--- a/test/test_vehicle.py
+++ b/test/test_vehicle.py
@@ -148,6 +148,7 @@ async def test_available_attributes(caplog):
         "remaining_range_total",
         "mileage",
         "charging_time_remaining",
+        "charging_start_time",
         "charging_end_time",
         "charging_time_label",
         "charging_status",
@@ -155,6 +156,11 @@ async def test_available_attributes(caplog):
         "remaining_battery_percent",
         "remaining_range_electric",
         "last_charging_end_result",
+        "ac_current_limit",
+        "charging_target",
+        "charging_mode",
+        "charging_preferences",
+        "is_pre_entry_climatization_enabled",
         "remaining_fuel",
         "remaining_range_fuel",
         "remaining_fuel_percent",
@@ -173,6 +179,7 @@ async def test_available_attributes(caplog):
         "remaining_range_total",
         "mileage",
         "charging_time_remaining",
+        "charging_start_time",
         "charging_end_time",
         "charging_time_label",
         "charging_status",
@@ -180,6 +187,11 @@ async def test_available_attributes(caplog):
         "remaining_battery_percent",
         "remaining_range_electric",
         "last_charging_end_result",
+        "ac_current_limit",
+        "charging_target",
+        "charging_mode",
+        "charging_preferences",
+        "is_pre_entry_climatization_enabled",
         "condition_based_services",
         "check_control_messages",
         "door_lock_state",