Skip to content

Commit

Permalink
Merge pull request #143 from itchannel/1.28
Browse files Browse the repository at this point in the history
Added vin check on setup
  • Loading branch information
itchannel committed Dec 16, 2021
2 parents 2f712bf + 3233dd8 commit 831bda1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 30 deletions.
14 changes: 8 additions & 6 deletions custom_components/fordpass/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ async def validate_input(hass: core.HomeAssistant, data):
except Exception as ex:
raise InvalidAuth from ex

try:
result3 = await hass.async_add_executor_job(vehicle.vehicles)
# raise InvalidVin
except Exception as ex:
raise InvalidVin from ex

result3 = await hass.async_add_executor_job(vehicle.vehicles)
vinfound = False
for car in result3:
if car["vin"] == data[VIN]:
vinfound = True
if vinfound == False:
raise InvalidVin

if not result:
_LOGGER.error("Failed to authenticate with fordpass")
raise CannotConnect
Expand Down
23 changes: 1 addition & 22 deletions custom_components/fordpass/fordpass_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,28 +259,7 @@ def vehicles(self):
result = r.json()

_LOGGER.debug(result)
return result["vehicleCapabilities"]
else:
_LOGGER.debug(r.text)
r.raise_for_status()

def vehicles(self):
self.__acquireToken()

headers = {
**apiHeaders,
"Auth-Token": self.token,
"Application-Id": self.region,
}
r = session.get(
"https://services.cx.ford.com/api/dashboard/v1/users/vehicles",
headers=headers,
)
if r.status_code == 200:
result = r.json()

_LOGGER.debug(result)
return result["vehicleCapabilities"]
return result
else:
_LOGGER.debug(r.text)
r.raise_for_status()
Expand Down
2 changes: 1 addition & 1 deletion custom_components/fordpass/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config_flow": true,
"documentation": "https://github.com/itchannel/fordpass-ha",
"issue_tracker": "https://github.com/itchannel/fordpass-ha/issues",
"version": "0.1.27",
"version": "0.1.28",
"requirements": ["dotted==0.1.8"],
"ssdp": [],
"zeroconf": [],
Expand Down
2 changes: 1 addition & 1 deletion custom_components/fordpass/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"error": {
"cannot_connect": "Failed to connect",
"invalid_auth": "Invalid authentication",
"invalid_vin": "Vin not found",
"invalid_vin": "Vin not found for given account",
"unknown": "Unexpected error"
},
"step": {
Expand Down
2 changes: 2 additions & 0 deletions info.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

# **Changelog**
### Version 1.28
- Added vin check on setup (Will check if given VIN is linked to the credentials)
### Version 1.27
- Fix fuel level error
- Add code for Vin debugging
Expand Down

0 comments on commit 831bda1

Please sign in to comment.