Skip to content
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
10 changes: 8 additions & 2 deletions homeassistant/components/tesla_fleet/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ async def wake_up_vehicle(vehicle: TeslaFleetVehicleData) -> None:
cmd = await vehicle.api.vehicle()
state = cmd["response"]["state"]
except TeslaFleetError as e:
raise HomeAssistantError(str(e)) from e
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="wake_up_failed",
) from e
vehicle.coordinator.data["state"] = state
if state != TeslaFleetState.ONLINE:
times += 1
if times >= 4: # Give up after 30 seconds total
raise HomeAssistantError("Could not wake up vehicle")
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="wake_up_timeout",
)
await asyncio.sleep(times * 5)


Expand Down
15 changes: 15 additions & 0 deletions homeassistant/components/tesla_fleet/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
"data": {
"domain": "Domain"
},
"data_description": {
"domain": "The domain that hosts your public key for Tesla Fleet API authentication."
},
"description": "Enter the domain that will host your public key. This is typically the domain of the origin you specified during registration at {dashboard}.",
"title": "Tesla Fleet domain registration"
},
Expand All @@ -51,6 +54,12 @@
"title": "[%key:common::config_flow::title::reauth%]"
},
"registration_complete": {
"data": {
"qr_code": "QR code"
},
"data_description": {
"qr_code": "Scan this QR code with your phone to set up the virtual key."
},
"description": "To enable command signing, you must open the Tesla app, select your vehicle, and then visit the following URL to set up a virtual key. You must repeat this process for each vehicle.\n\n{virtual_key_url}",
"title": "Command signing"
}
Expand Down Expand Up @@ -623,6 +632,12 @@
},
"update_failed": {
"message": "{endpoint} data request failed: {message}"
},
"wake_up_failed": {
"message": "Failed to wake up vehicle"
},
"wake_up_timeout": {
"message": "Could not wake up vehicle"
}
}
}
3 changes: 2 additions & 1 deletion tests/components/tesla_fleet/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ async def test_asleep_or_offline(
# Run a command but fail trying to wake up the vehicle
mock_wake_up.side_effect = InvalidCommand
with pytest.raises(
HomeAssistantError, match="The data request or command is unknown."
HomeAssistantError,
match="Failed to wake up vehicle",
):
await hass.services.async_call(
CLIMATE_DOMAIN,
Expand Down