Skip to content

Commit

Permalink
Merge pull request #269 from Kolbi/Kolbi-patch-1
Browse files Browse the repository at this point in the history
fix: more validate-hassfest & pre-commit fixes
  • Loading branch information
cdnninja authored Mar 8, 2024
2 parents 77e36ba + 9f56ba3 commit 82f9d37
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 34 deletions.
16 changes: 8 additions & 8 deletions custom_components/audiconnect/audi_connect_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,13 +836,13 @@ def oil_level(self):
"""Return oil level percentage"""
if self.oil_level_supported:
val = self._vehicle.fields.get("OIL_LEVEL_DIPSTICKS_PERCENTAGE")
if type(val) is bool:
if val:
return 100
else:
return 1
if parse_float(val):
return True
if isinstance(val, bool):
if val:
return 100
else:
return 1
elif parse_float(val):
return parse_float(val)

@property
def oil_level_supported(self):
Expand Down Expand Up @@ -911,7 +911,7 @@ def parking_light(self):
try:
check = self._vehicle.fields.get("LIGHT_STATUS")
return check[0]["status"] != "off" or check[1]["status"] != "off"
except:
except KeyError:
return False

@property
Expand Down
10 changes: 4 additions & 6 deletions custom_components/audiconnect/audi_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ def __init__(self, api: AudiAPI, country: str, spin: str):
def get_hidden_html_input_form_data(self, response, form_data: Dict[str, str]):
# Now parse the html body and extract the target url, csrf token and other required parameters
html = BeautifulSoup(response, "html.parser")
form_tag = html.find("form")

form_inputs = html.find_all("input", attrs={"type": "hidden"})
for form_input in form_inputs:
name = form_input.get("name")
Expand Down Expand Up @@ -290,7 +288,7 @@ async def get_vehicle_information(self):

async def get_vehicle_data(self, vin: str):
self._api.use_token(self.vwToken)
data = await self._api.get(
return await self._api.get(
"{homeRegion}/fs-car/vehicleMgmt/vehicledata/v2/{type}/{country}/vehicles/{vin}/".format(
homeRegion=await self._get_home_region(vin.upper()),
type=self._type,
Expand Down Expand Up @@ -880,9 +878,9 @@ async def login_request(self, user: str, password: str):
self._tokenEndpoint = "https://emea.bff.cariad.digital/login/v1/idk/token"
if "token_endpoint" in openidcfg_json:
self._tokenEndpoint = openidcfg_json["token_endpoint"]
revocation_endpoint = "https://emea.bff.cariad.digital/login/v1/idk/revoke"
if "revocation_endpoint" in openidcfg_json:
revocation_endpoint = openidcfg_json["revocation_endpoint"]
# revocation_endpoint = "https://emea.bff.cariad.digital/login/v1/idk/revoke"
# if "revocation_endpoint" in openidcfg_json:
# revocation_endpoint = openidcfg_json["revocation_endpoint"]

# generate code_challenge
code_verifier = str(base64.urlsafe_b64encode(os.urandom(32)), "utf-8").strip(
Expand Down
4 changes: 2 additions & 2 deletions custom_components/audiconnect/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def async_step_user(self, user_input=None):
spin=self._spin,
)

if await connection.try_login(False) == False:
if await connection.try_login(False) is False:
raise Exception(
"Unexpected error communicating with the Audi server"
)
Expand Down Expand Up @@ -129,7 +129,7 @@ async def async_step_import(self, user_input):
spin=spin,
)

if await connection.try_login(False) == False:
if await connection.try_login(False) is False:
raise Exception("Unexpected error communicating with the Audi server")

except Exception:
Expand Down
20 changes: 13 additions & 7 deletions custom_components/audiconnect/services.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
# Describes the format for available services for audiconnect

refresh_vehicle_data:
name: Refresh vehicle data
description: >
Request an update of the state from the vehicle, as opposed to the normal update
mechanism, which only retrieves data from the servers.
Request an update of the state from the vehicle, as opposed to the normal
update mechanism, which only retrieves data from the servers.
fields:
vin:
name: VIN
description: >
The vehicle identification number (VIN) of the vehicle, 17 characters
example: WBANXXXXXX1234567

execute_vehicle_action:
name: Execute Vehicle Action
description: >
Request an update of the state from the vehicle, as opposed to the normal update
mechanism, which only retrieves data from the servers.
Execute Vehicle actions
fields:
vin:
name: VIN
description: >
The vehicle identification number (VIN) of the vehicle, 17 characters
example: WBANXXXXXX1234567
action:
name: Action
description: >
The action to be executed. Possible choices, depending on subscription options, include 'lock', 'unlock',
'start_climatisation', 'stop_climatisation, 'start_charger', 'start_timed_charger', 'stop_charger',
'start_preheater', 'stop_preheater, 'start_window_heating', 'stop_window_heating'
The action to be executed. Possible choices, depending on subscription
options, include 'lock', 'unlock', 'start_climatisation',
'stop_climatisation, 'start_charger', 'start_timed_charger',
'stop_charger', 'start_preheater', 'stop_preheater,
'start_window_heating', 'stop_window_heating'
example: lock
1 change: 0 additions & 1 deletion custom_components/audiconnect/strings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"config": {
"title": "Audi Connect",
"step": {
"user": {
"title": "Please fill in the information of your Audi Connect account",
Expand Down
3 changes: 1 addition & 2 deletions custom_components/audiconnect/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
},
"title": "Audi Connect Kontoinformationen"
}
},
"title": "Audi Connect"
}
}
}
3 changes: 1 addition & 2 deletions custom_components/audiconnect/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
},
"title": "Audi Connect Account Info"
}
},
"title": "Audi Connect"
}
}
}
3 changes: 1 addition & 2 deletions custom_components/audiconnect/translations/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
},
"title": "Audi Connect kontoinformasjon"
}
},
"title": "Audi Connect"
}
}
}
3 changes: 1 addition & 2 deletions custom_components/audiconnect/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
},
"title": "Audi Connect accountgegevens"
}
},
"title": "Audi Connect"
}
}
}
3 changes: 1 addition & 2 deletions custom_components/audiconnect/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
},
"title": "Informações da conta Audi Connect "
}
},
"title": "Audi Connect"
}
}
}

0 comments on commit 82f9d37

Please sign in to comment.