Skip to content

Commit

Permalink
Merge pull request #1072 from alandtse/dev
Browse files Browse the repository at this point in the history
chore: release 2024-11-26
  • Loading branch information
alandtse authored Nov 27, 2024
2 parents 12d9df7 + a208759 commit 56d4a1c
Show file tree
Hide file tree
Showing 9 changed files with 2,322 additions and 1,976 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ repos:
- hooks:
- id: black
repo: https://github.com/psf/black
rev: 24.4.2
rev: 24.10.0
- repo: https://github.com/pre-commit/mirrors-prettier
hooks:
- id: prettier
Expand All @@ -71,7 +71,7 @@ repos:
# - id: prospector
# exclude: ^(tests)/.+\.py$
- repo: https://github.com/PyCQA/bandit
rev: 1.7.8
rev: 1.7.10
hooks:
- id: bandit
args:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/tesla_custom/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/alandtse/tesla/issues",
"loggers": ["teslajsonpy"],
"requirements": ["teslajsonpy==3.12.0"],
"requirements": ["teslajsonpy==3.12.3"],
"version": "3.24.2"
}
2 changes: 1 addition & 1 deletion custom_components/tesla_custom/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async def api(call):
command,
parameters,
)
path_vars = parameters.pop(ATTR_PATH_VARS)
path_vars = parameters.pop(ATTR_PATH_VARS, {})
response = await controller.api(name=command, path_vars=path_vars, **parameters)
return response

Expand Down
25 changes: 18 additions & 7 deletions custom_components/tesla_custom/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,34 @@ def installed_version(self) -> str:
return version_str

@property
def in_progress(self):
def in_progress(self) -> bool:
"""Get Progress, if updating."""
update_status = None

if self._car.software_update:
update_status = self._car.software_update.get("status")
# If the update is scheduled, don't consider in-progress so the
# user can still install immediately if desired
if update_status == "scheduled":
return False
# If its actually installing, we can use the install_perc
if update_status == "installing":
progress = self._car.software_update.get("install_perc")
return progress
return True
# Otherwise, we're not updating, so return False
return False

@property
def update_percentage(self) -> int | None:
"""Get update percentate, if updating."""
update_status = None

if self._car.software_update:
update_status = self._car.software_update.get("status")

# If its actually installing, we can use the install_perc
if update_status == "installing":
install_perc = self._car.software_update.get("install_perc")
return install_perc

# Otherwise, we're not updating, so return None
return None

async def async_install(self, version, backup: bool, **kwargs: Any) -> None:
"""Install an Update."""
# Ask Tesla to start the update now.
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Tesla",
"hacs": "1.6.0",
"homeassistant": "2023.7.0",
"homeassistant": "2024.11.0",
"zip_release": true,
"filename": "tesla_custom.zip"
}
4,248 changes: 2,288 additions & 1,960 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ license = "Apache-2.0"

[tool.poetry.dependencies]
python = ">=3.12,<3.13"
teslajsonpy = "3.12.0"
teslajsonpy = "3.12.3"
async-timeout = ">=4.0.0"


[tool.poetry.group.dev.dependencies]
homeassistant = ">=2024.3.0"
homeassistant = ">=2024.11.0"
pytest-homeassistant-custom-component = ">=0.13.107"
bandit = ">=1.7.0"
black = { version = ">=21.12b0", allow-prereleases = true }
mypy = ">=0.812"
pre-commit = ">=2.11.1"

pydocstyle = ">=6.0.0"
prospector = { extras = ["with_all"], version = ">=1.3.1" }
aiohttp_cors = ">=0.7.0"
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ poetry config virtualenvs.create false
poetry install --no-interaction

# Keep this inline with any requirements that are in manifest.json
pip install git+https://github.com/zabuldon/teslajsonpy.git@dev#teslajsonpy==3.12.0
pip install git+https://github.com/zabuldon/teslajsonpy.git@dev#teslajsonpy==3.12.3
pre-commit install --install-hooks
8 changes: 7 additions & 1 deletion tests/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ async def test_status_download_wait_wifi(hass: HomeAssistant) -> None:
assert state.attributes.get("latest_version") == "2022.36.20 (Waiting on Wi-Fi)"
assert state.attributes.get("installed_version") == "2022.8.10.1"
assert state.attributes.get("in_progress") is False
assert state.attributes.get("update_percentage") is None
assert (
state.attributes.get("release_url")
== "https://www.notateslaapp.com/software-updates/version/2022.36.20/release-notes"
Expand Down Expand Up @@ -67,6 +68,7 @@ async def test_status_downloading(hass: HomeAssistant) -> None:
assert state.attributes.get("latest_version") == "2022.36.20 (Downloading)"
assert state.attributes.get("installed_version") == "2022.8.10.1"
assert state.attributes.get("in_progress") is False
assert state.attributes.get("update_percentage") is None
assert (
state.attributes.get("release_url")
== "https://www.notateslaapp.com/software-updates/version/2022.36.20/release-notes"
Expand Down Expand Up @@ -96,6 +98,7 @@ async def test_status_available(hass: HomeAssistant) -> None:
assert state.attributes.get("latest_version") == "2022.36.20 (Available to install)"
assert state.attributes.get("installed_version") == "2022.8.10.1"
assert state.attributes.get("in_progress") is False
assert state.attributes.get("update_percentage") is None
assert (
state.attributes.get("release_url")
== "https://www.notateslaapp.com/software-updates/version/2022.36.20/release-notes"
Expand Down Expand Up @@ -132,6 +135,7 @@ async def test_status_scheduled(hass: HomeAssistant) -> None:
)
assert state.attributes.get("installed_version") == "2022.8.10.1"
assert state.attributes.get("in_progress") is False
assert state.attributes.get("update_percentage") is None
assert (
state.attributes.get("release_url")
== "https://www.notateslaapp.com/software-updates/version/2022.36.20/release-notes"
Expand Down Expand Up @@ -163,7 +167,8 @@ async def test_status_installing(hass: HomeAssistant) -> None:
assert state.state == STATE_ON
assert state.attributes.get("latest_version") == "2022.36.20 (Installing)"
assert state.attributes.get("installed_version") == "2022.8.10.1"
assert state.attributes.get("in_progress") == 30
assert state.attributes.get("in_progress") is True
assert state.attributes.get("update_percentage") == 30
assert (
state.attributes.get("release_url")
== "https://www.notateslaapp.com/software-updates/version/2022.36.20/release-notes"
Expand Down Expand Up @@ -193,6 +198,7 @@ async def test_status_none(hass: HomeAssistant) -> None:
assert state.attributes.get("latest_version") == "2022.8.10.1"
assert state.attributes.get("installed_version") == "2022.8.10.1"
assert state.attributes.get("in_progress") is False
assert state.attributes.get("update_percentage") is None
assert (
state.attributes.get("release_url")
== "https://www.notateslaapp.com/software-updates/version/2022.8.10.1/release-notes"
Expand Down

0 comments on commit 56d4a1c

Please sign in to comment.