Repository: bimmerconnected/bimmer_connected
Pull request #234 (2020-11-05 08:15:57)

0.7.12
## 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.
-->
- Fix US login issues (715f44b) @rikroe 
- Add vehicle position heading (#227) @EddyK69 
- Update templates & readme for Github Discussions @gerard33 

## Type of change
- [x] 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/.github/ISSUE_TEMPLATE/issue-template.md b/.github/ISSUE_TEMPLATE/bug-report.md
similarity index 69%
rename from .github/ISSUE_TEMPLATE/issue-template.md
rename to .github/ISSUE_TEMPLATE/bug-report.md
index eb28784..bc7b834 100644
--- a/.github/ISSUE_TEMPLATE/issue-template.md
+++ b/.github/ISSUE_TEMPLATE/bug-report.md
@@ -1,9 +1,7 @@
 ---
-name: Issue template
-about: Describe this issue here
-title: ''
-labels: ''
-assignees: ''
+name: Bug report
+about: Report an issue related to bimmer_connected
+labels: 'bug :bug:'
 
 ---
 
@@ -15,7 +13,7 @@ A clear and concise description of what the issue is.
 
 A clear and concise description of what you expected to happen.
 
-**Home Assistant version**
+**Home Assistant version (if used)**
 
 Which Home Assistant version are you using?
 
@@ -25,11 +23,11 @@ And did it work on a previous version, if so what was the last working version?
 
 If applicable, add screenshots to help explain your problem.
 
-**Connected Drive website**
+**ConnectedDrive website**
 
-If you see any issues with the BMW integration in Home Assistant (or when directly using the library), please make sure to first login to the BMW Connected Drive website of your country and check if you can successfully login and query the car status.
-- [ ] I can still successfully login to the BMW Connected Drive website and the car status is available there.
-- [ ] I have Connected Drive enabled for my vehicle.
+If you see any issues with the BMW integration in Home Assistant (or when directly using the library), please make sure to first login to the BMW ConnectedDrive website of your country and check if you can successfully login and query the car status.
+- [ ] I can still successfully login to the BMW ConnectedDrive website and the car status is available there.
+- [ ] I have ConnectedDrive enabled for my vehicle.
 
 **Your config.yaml**
 
@@ -44,7 +42,7 @@ bmw_connected_drive:
 **Number of cars**
 
 If you have more than 1 car please mention that here.
-- [ ] I have 2 or more cars linked to the Connected Drive account.
+- [ ] I have 2 or more cars linked to the ConnectedDrive account.
 - [ ] I have a Mini vehicle linked to my account.
 
 **Output of bimmer_connected fingerprint**
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 0000000..96bbf25
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,17 @@
+blank_issues_enabled: false
+contact_links:
+  - name: Request a feature for bimmer_connected
+    url: https://github.com/bimmerconnected/bimmer_connected/discussions/category_choices
+    about: Request an new feature for the bimmer_connected library.
+  - name: Fingerprint data contributions
+    url: https://github.com/bimmerconnected/bimmer_connected/discussions/category_choices
+    about: If some features do not work for your vehicle, we would need the data returned form the server to analyse this and potentially extend the code.
+  - name: Q&A
+    url: https://github.com/bimmerconnected/bimmer_connected/discussions/category_choices
+    about: Ask the community for help
+  - name: Show and tell
+    url: https://github.com/bimmerconnected/bimmer_connected/discussions/category_choices
+    about: We use GitHub for tracking bugs, check our website for resources on getting help.
+  - name: General
+    url: https://github.com/bimmerconnected/bimmer_connected/discussions/category_choices
+    about: Chat that doesn't fit anywhere else
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
deleted file mode 100644
index 8babc92..0000000
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ /dev/null
@@ -1,22 +0,0 @@
----
-name: Feature request
-about: Suggest an idea for this project
-title: ''
-labels: ''
-assignees: ''
-
----
-
-**Is your feature request related to a problem? Please describe.**
-A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
-
-**Describe the solution you'd like**
-A clear and concise description of what you want to happen.
-
-**Describe alternatives you've considered**
-A clear and concise description of any alternative solutions or features you've considered.
-
-**Additional context**
-Add any other context or screenshots about the feature request here.
-
-*NOTE: It might take me a while to respond on GitHub (I only maintain this in my free time), but I will respond.*
diff --git a/README.rst b/README.rst
index 4a5b486..651e97e 100644
--- a/README.rst
+++ b/README.rst
@@ -17,7 +17,7 @@ bimmer_connected
     :target: https://coveralls.io/github/bimmerconnected/bimmer_connected?branch=master
 
 This is a simple library to query and control the status of your BMW or Mini vehicle from
-the Connected Drive portal.
+the ConnectedDrive portal.
 
 
 Installation
@@ -41,13 +41,13 @@ This library is written to be included in `Home Assistant <https://www.home-assi
 
 Compatibility
 =============
-This works with BMW (and Mini) vehicles with a Connected Drive account.
+This works with BMW (and Mini) vehicles with a ConnectedDrive account.
 So far it is tested on vehicles with a 'MGU', 'NBTEvo', 'EntryEvo', 'NBT', or 'EntryNav'
 navigation system. If you have any trouble with other navigation systems, please create 
 an issue with your server responses (see next section).
 
 To use this library, your BMW (or Mini) must have the remote services enabled for your vehicle. 
-You might need to book this in the Connected Drive/Mini Connected portal and this might cost 
+You might need to book this in the ConnectedDrive/Mini Connected portal and this might cost 
 some money. In addition to that you need to enable the Remote Services in your infotainment 
 system in the vehicle.
 
@@ -80,12 +80,11 @@ The following attributes are by default replaced with anonymized values:
 * :code:`vin` (Vehicle Identification Number)
 * :code:`lat` and :code:`lon` (GPS position)
 * :code:`licensePlate`
+* :code:`information of dealer`
 
 Create a new
-`issue in bimmer_connected <https://github.com/bimmerconnected/bimmer_connected/issues>`_
-and
-`add the files as attachment <https://help.github.com/articles/file-attachments-on-issues-and-pull-requests/>`_
-to the issue.
+`fingerprint data contribution <https://github.com/bimmerconnected/bimmer_connected/discussions/new?category_id=32000818>`_
+and add the files as attachment to the discussion.
 
 Please add your model and year to the title of the issue, to make it easier to organize. 
 If you know the "chassis code" of your car, you can include that too. (For example, 
diff --git a/bimmer_connected/country_selector.py b/bimmer_connected/country_selector.py
index 3de9679..300d077 100644
--- a/bimmer_connected/country_selector.py
+++ b/bimmer_connected/country_selector.py
@@ -22,7 +22,7 @@ _SERVER_URLS = {
 
 #: Mapping from regions to servers
 _GCDM_OAUTH_ENDPOINTS = {
-    Regions.NORTH_AMERICA: 'customer.bmwgroup.com/gcdm/usa',
+    Regions.NORTH_AMERICA: 'b2vapi.bmwgroup.us/gcdm',
     Regions.REST_OF_WORLD: 'customer.bmwgroup.com/gcdm',
     Regions.CHINA: 'customer.bmwgroup.cn/gcdm'
 }
diff --git a/bimmer_connected/vehicle_status.py b/bimmer_connected/vehicle_status.py
index 19552ff..fae550c 100644
--- a/bimmer_connected/vehicle_status.py
+++ b/bimmer_connected/vehicle_status.py
@@ -136,13 +136,25 @@ class VehicleStatus:  # pylint: disable=too-many-public-methods
         Returns a tuple of (latitude, longitude).
         This only provides data, if the vehicle tracking is enabled!
         """
-        pos = self._state.attributes[SERVICE_STATUS]['position']
         if not self.is_vehicle_tracking_enabled:
-            _LOGGER.warning('Positioning status is %s', pos['status'])
+            _LOGGER.warning('Vehicle tracking is disabled')
             return None
         pos = self._state.attributes[SERVICE_STATUS]['position']
         return float(pos['lat']), float(pos['lon'])
 
+    @property
+    @backend_parameter
+    def gps_heading(self) -> (int):
+        """Get the last known heading of the vehicle.
+
+        This only provides data, if the vehicle tracking is enabled!
+        """
+        if not self.is_vehicle_tracking_enabled:
+            _LOGGER.warning('Vehicle tracking is disabled')
+            return None
+        pos = self._state.attributes[SERVICE_STATUS]['position']
+        return int(pos['heading'])
+
     @property
     @backend_parameter
     def is_vehicle_tracking_enabled(self) -> bool:


Test patch:
diff --git a/test/test_vehicle_status.py b/test/test_vehicle_status.py
index 1708772..d33d99e 100644
--- a/test/test_vehicle_status.py
+++ b/test/test_vehicle_status.py
@@ -37,6 +37,7 @@ class TestState(unittest.TestCase):
         self.assertTrue(state.vehicle_status.is_vehicle_tracking_enabled)
         self.assertAlmostEqual(50.5050, state.vehicle_status.gps_position[0])
         self.assertAlmostEqual(10.1010, state.vehicle_status.gps_position[1])
+        self.assertAlmostEqual(174, state.vehicle_status.gps_heading)
 
         self.assertAlmostEqual(33, state.vehicle_status.remaining_fuel)
 
@@ -68,6 +69,7 @@ class TestState(unittest.TestCase):
 
         self.assertFalse(state.vehicle_status.is_vehicle_tracking_enabled)
         self.assertIsNone(state.vehicle_status.gps_position)
+        self.assertIsNone(state.vehicle_status.gps_heading)
 
     def test_parse_f48(self):
         """Test if the parsing of the attributes is working."""
@@ -84,6 +86,7 @@ class TestState(unittest.TestCase):
         self.assertTrue(state.vehicle_status.is_vehicle_tracking_enabled)
         self.assertAlmostEqual(50.505050, state.vehicle_status.gps_position[0])
         self.assertAlmostEqual(10.1010101, state.vehicle_status.gps_position[1])
+        self.assertAlmostEqual(141, state.vehicle_status.gps_heading)
 
         self.assertAlmostEqual(39, state.vehicle_status.remaining_fuel)