From 6d1a3eccf088ccff0fde7214274a4dffb0bf1be4 Mon Sep 17 00:00:00 2001 From: Elliott Balsley <3991046+llamafilm@users.noreply.github.com> Date: Tue, 12 Mar 2024 15:53:09 -0700 Subject: [PATCH 1/4] fix: set default client_id ownerapi (#896) closes #895 --- custom_components/tesla_custom/config_flow.py | 2 +- tests/test_config_flow.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/tesla_custom/config_flow.py b/custom_components/tesla_custom/config_flow.py index aa7cf54b..e0b9c11a 100644 --- a/custom_components/tesla_custom/config_flow.py +++ b/custom_components/tesla_custom/config_flow.py @@ -279,7 +279,7 @@ async def validate_input(hass: core.HomeAssistant, data) -> dict: config[CONF_INCLUDE_ENERGYSITES] = data[CONF_INCLUDE_ENERGYSITES] config[CONF_API_PROXY_URL] = data.get(CONF_API_PROXY_URL) config[CONF_API_PROXY_CERT] = data.get(CONF_API_PROXY_CERT) - config[CONF_CLIENT_ID] = data.get(CONF_CLIENT_ID) + config[CONF_CLIENT_ID] = data.get(CONF_CLIENT_ID, "ownerapi") except IncompleteCredentials as ex: _LOGGER.error("Authentication error: %s %s", ex.message, ex) diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 69857ce6..2dd2c709 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -97,7 +97,7 @@ async def test_form(hass): "initial_setup": True, CONF_API_PROXY_URL: None, CONF_API_PROXY_CERT: None, - CONF_CLIENT_ID: None, + CONF_CLIENT_ID: "ownerapi", } assert len(mock_setup.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1 @@ -344,7 +344,7 @@ async def test_import(hass): CONF_API_PROXY_ENABLE: False, CONF_API_PROXY_CERT: None, CONF_API_PROXY_URL: None, - CONF_CLIENT_ID: None, + CONF_CLIENT_ID: "ownerapi", }, ) assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY From 52d782d5a4a84e09eed30b204132a096cf105aa6 Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 12 Mar 2024 22:54:23 +0000 Subject: [PATCH 2/4] [skip ci] 3.20.2 Automatically generated by python-semantic-release --- custom_components/tesla_custom/const.py | 2 +- custom_components/tesla_custom/manifest.json | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/tesla_custom/const.py b/custom_components/tesla_custom/const.py index d06b473f..43ac1a3e 100644 --- a/custom_components/tesla_custom/const.py +++ b/custom_components/tesla_custom/const.py @@ -1,6 +1,6 @@ """Const file for Tesla cars.""" -VERSION = "3.20.1" +VERSION = "3.20.2" CONF_EXPIRATION = "expiration" CONF_INCLUDE_VEHICLES = "include_vehicles" CONF_INCLUDE_ENERGYSITES = "include_energysites" diff --git a/custom_components/tesla_custom/manifest.json b/custom_components/tesla_custom/manifest.json index 39fd301b..3ef569e7 100644 --- a/custom_components/tesla_custom/manifest.json +++ b/custom_components/tesla_custom/manifest.json @@ -25,5 +25,5 @@ "issue_tracker": "https://github.com/alandtse/tesla/issues", "loggers": ["teslajsonpy"], "requirements": ["teslajsonpy==3.10.1"], - "version": "3.20.1" + "version": "3.20.2" } diff --git a/pyproject.toml b/pyproject.toml index 0a5d4ed2..46be1694 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "tesla" -version = "3.20.1" +version = "3.20.2" description = "A fork of the Home Assistant tesla integration using a oauth proxy to login." authors = ["Alan D. Tse "] license = "Apache-2.0" From 57259d98ca82361572d96d82229e20b77d22c917 Mon Sep 17 00:00:00 2001 From: Elliott Balsley <3991046+llamafilm@users.noreply.github.com> Date: Thu, 14 Mar 2024 02:17:05 -0700 Subject: [PATCH 3/4] fix: UnboundLocalError when supervised without addon (#904) --- custom_components/tesla_custom/config_flow.py | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/custom_components/tesla_custom/config_flow.py b/custom_components/tesla_custom/config_flow.py index e0b9c11a..513240b5 100644 --- a/custom_components/tesla_custom/config_flow.py +++ b/custom_components/tesla_custom/config_flow.py @@ -146,11 +146,11 @@ def _async_schema(self, api_proxy_enable: bool): } ) + api_proxy_cert = api_proxy_url = client_id = None if api_proxy_enable: # autofill fields if HTTP Proxy is running as addon if "SUPERVISOR_TOKEN" in os.environ: - api_proxy_cert = "/share/tesla/selfsigned.pem" - + _LOGGER.debug("Running in supervised environment") # find out if addon is running from normal repo or local req = httpx.get( "http://supervisor/addons", @@ -162,21 +162,21 @@ def _async_schema(self, api_proxy_enable: bool): if addon["name"] == "Tesla HTTP Proxy": addon_slug = addon["slug"] break - if not addon_slug: - _LOGGER.warning("Unable to communicate with Tesla HTTP Proxy addon") - - # read Client ID from addon - req = httpx.get( - f"http://supervisor/addons/{addon_slug}/info", - headers={ - "Authorization": f"Bearer {os.environ['SUPERVISOR_TOKEN']}" - }, - ) - client_id = req.json()["data"]["options"]["client_id"] - api_proxy_url = "https://" + req.json()["data"]["hostname"] - else: - api_proxy_url = client_id = api_proxy_cert = None + try: + # read Client ID from addon + req = httpx.get( + f"http://supervisor/addons/{addon_slug}/info", + headers={ + "Authorization": f"Bearer {os.environ['SUPERVISOR_TOKEN']}" + }, + ) + client_id = req.json()["data"]["options"]["client_id"] + api_proxy_url = "https://" + req.json()["data"]["hostname"] + api_proxy_cert = "/share/tesla/selfsigned.pem" + _LOGGER.debug("Found addon: %s", addon_slug) + except NameError: + _LOGGER.warning("Unable to communicate with Tesla HTTP Proxy addon") schema = schema.extend( { From 9b09753beefe9cc5637b9da1d846d819a7a7b125 Mon Sep 17 00:00:00 2001 From: Stephen Jones Date: Thu, 14 Mar 2024 09:18:19 +0000 Subject: [PATCH 4/4] chore: Ensure issues are created using templates (#900) Co-authored-by: Alan Tse --- .github/ISSUE_TEMPLATE/config.yml | 1 + .github/ISSUE_TEMPLATE/issue_powerwall.yml | 74 ++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/issue_powerwall.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..3ba13e0c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false diff --git a/.github/ISSUE_TEMPLATE/issue_powerwall.yml b/.github/ISSUE_TEMPLATE/issue_powerwall.yml new file mode 100644 index 00000000..454346fa --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue_powerwall.yml @@ -0,0 +1,74 @@ +name: Powerwall Issue +description: Create a report to help us improve +title: "Powerwall Issue: " +labels: ["triage", "powerwall"] +body: + - type: checkboxes + attributes: + label: Is there an existing issue for this? + description: Before you open a new issue, search through the existing open issues and closed issues to see if others have had the same problem. + options: + - label: I have searched both the existing open issues & recently closed issues and did not find a duplicate of this issue. + required: true + - type: markdown + attributes: + value: | + Issues not containing the minimum requirements will be closed: + - Issues without a description (using the header is not good enough) will be closed. + - Issues without debug logging will be closed. + + - type: input + id: version_hacs + attributes: + label: Version of the Tesla component + description: You can find this under HACS -> Integrations -> Tesla. If you are not using the newest version, download and try that before opening an issue + placeholder: ex. v3.19.3 + validations: + required: true + - type: input + id: version_tesla + attributes: + label: Version of the Powerwall Gateway software + description: Open the Tesla app -> Select powerwall -> Settings -> My Home Info -> Powerwall Gateway Version + placeholder: ex. 23.44.0 eb113390 + validations: + required: true + - type: input + id: model_powerwall + attributes: + label: Model + description: The model of the Powerwall + placeholder: ex. 2 + validations: + required: true + - type: textarea + attributes: + label: Current Behavior + description: A concise description of what you're experiencing. + validations: + required: true + + - type: textarea + attributes: + label: Expected Behavior + description: A concise description of what you expected to happen. + validations: + required: true + + - type: textarea + attributes: + label: Debug logs + description: Enable the debug logs ([In Home Assistant](https://my.home-assistant.io/redirect/integration/?domain=tesla_custom) & click `Enable debug logging`) + render: true + placeholder: | + Your logs here + validations: + required: true + + - type: textarea + attributes: + label: Anything else? + description: | + Links? References? Anything that will give us more context about the issue you are encountering + validations: + required: false