Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update entity with HA 2024.11 #1069

Merged
merged 4 commits into from
Nov 26, 2024
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
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
Loading