Skip to content

Commit

Permalink
fix: update entity with HA 2024.11 (#1069)
Browse files Browse the repository at this point in the history
* Add update_percentage and make in_progress a boolean

* Update home assistant version to 2024.11

* Update poetry

* style: auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Erik Hendrix <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 26, 2024
1 parent 12d9df7 commit 3367ee5
Show file tree
Hide file tree
Showing 6 changed files with 2,242 additions and 1,916 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
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"
}
Loading

0 comments on commit 3367ee5

Please sign in to comment.