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: Bump teslajsonpy to 3.12.2 #1067

Closed
wants to merge 10 commits into from
Closed
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
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 @@ -5,11 +5,11 @@

import logging

import voluptuous as vol
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did black do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say yes, I didn't add it. :-)

from homeassistant.const import ATTR_COMMAND, CONF_EMAIL, CONF_SCAN_INTERVAL
from homeassistant.core import callback
from homeassistant.helpers import config_validation as cv
from teslajsonpy import Controller
import voluptuous as vol

from .const import (
ATTR_PARAMETERS,
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