From 6f1aefa3ea3b65adc5e65c86e3dbf02ad5878939 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Jun 2022 08:08:25 +0000 Subject: [PATCH 01/20] Update pytest-cov requirement from ~=2.12 to ~=3.0 Updates the requirements on [pytest-cov](https://github.com/pytest-dev/pytest-cov) to permit the latest version. - [Release notes](https://github.com/pytest-dev/pytest-cov/releases) - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-cov/compare/v2.12.0...v3.0.0) --- updated-dependencies: - dependency-name: pytest-cov dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-test.txt b/requirements-test.txt index 81a42bb..c12c533 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -6,5 +6,5 @@ mypy==0.960 pylint~=2.14 pylint-strict-informational==0.1 pytest~=7.1 -pytest-cov~=2.12 +pytest-cov~=3.0 pytest-homeassistant-custom-component>=0.8 From afa5399478da98691c1efffbf561321a7f0ddabb Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Fri, 3 Jun 2022 23:41:42 +0300 Subject: [PATCH 02/20] Remove 'domains' from hacs.json --- hacs.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hacs.json b/hacs.json index aa94fd4..d69d83f 100644 --- a/hacs.json +++ b/hacs.json @@ -1,11 +1,6 @@ { "name": "Integration blueprint", "hacs": "1.6.0", - "domains": [ - "binary_sensor", - "sensor", - "switch" - ], "iot_class": "Cloud Polling", "homeassistant": "0.118.0" } From 60b966c2239eaa91df80f9f3c9e03dbcb04e4056 Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Fri, 3 Jun 2022 23:44:45 +0300 Subject: [PATCH 03/20] Remove 'iot_class' from hacs.json --- hacs.json | 1 - 1 file changed, 1 deletion(-) diff --git a/hacs.json b/hacs.json index d69d83f..99ea29d 100644 --- a/hacs.json +++ b/hacs.json @@ -1,6 +1,5 @@ { "name": "Integration blueprint", "hacs": "1.6.0", - "iot_class": "Cloud Polling", "homeassistant": "0.118.0" } From 738c98fe0d6baab93175bbb396600b4ded8b699e Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Sat, 4 Jun 2022 16:15:44 +0300 Subject: [PATCH 04/20] Update release workflow --- .github/workflows/release.yml | 44 +++-------------------------------- 1 file changed, 3 insertions(+), 41 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ca0d07b..243e6e5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,49 +34,11 @@ jobs: run: | zip ${{ env.package }}.zip -r ./ - - name: "Upload zip to release" + - name: "Release" if: env.release_version != '' && success() - uses: svenstaro/upload-release-action@v2 + uses: softprops/action-gh-release@v1 with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ${{ env.basedir }}/${{ env.package }}.zip - asset_name: ${{ env.package }}.zip - tag: ${{ env.release_version }} - overwrite: true - - releasenotes: - name: "Prepare releasenotes" - runs-on: ubuntu-latest - steps: - - name: "Check out repository" - uses: actions/checkout@v3 - - - working-directory: ./custom_components - run: | - echo "release_version=$(git describe --abbrev=0 | sed s/v//)" >> $GITHUB_ENV - - - name: "Set up Python" - if: env.release_version != '' && success() - uses: actions/setup-python@v3 - with: - python-version: 3.9 - - - name: "Cache pip" - uses: actions/cache@v3 - with: - # This path is specific to Ubuntu - path: ~/.cache/pip - # Look to see if there is a cache hit for the corresponding requirements file - key: ${{ runner.os }}-pip-${{ hashFiles('requirements*.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - ${{ runner.os }}- - - - name: "Install requirements" - if: env.release_version != '' && success() - run: | - python3 -m pip install setuptools wheel - python3 -m pip install -r ./requirements-dev.txt + files: ${{ env.basedir }}/${{ env.package }}.zip - name: "Update release notes" if: env.release_version != '' && success() From 3c827e1435a1a13a4b1eddb788dc43a230bede3d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Jun 2022 14:07:23 +0000 Subject: [PATCH 05/20] Bump mypy from 0.960 to 0.961 Bumps [mypy](https://github.com/python/mypy) from 0.960 to 0.961. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.960...v0.961) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements-test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-test.txt b/requirements-test.txt index 81a42bb..e28a26f 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -2,7 +2,7 @@ asynctest~=0.13 flake8~=4.0 flake8-docstrings~=1.6 -mypy==0.960 +mypy==0.961 pylint~=2.14 pylint-strict-informational==0.1 pytest~=7.1 From e47590b38503dca0ae49b81718e395ca13dd1bfc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Jun 2022 14:07:26 +0000 Subject: [PATCH 06/20] Update pyupgrade requirement from ~=2.32 to ~=2.34 Updates the requirements on [pyupgrade](https://github.com/asottile/pyupgrade) to permit the latest version. - [Release notes](https://github.com/asottile/pyupgrade/releases) - [Commits](https://github.com/asottile/pyupgrade/compare/v2.32.0...v2.34.0) --- updated-dependencies: - dependency-name: pyupgrade dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index fb8039b..8226a88 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,5 +3,5 @@ black==22.3.0 packaging==21.3 pre-commit~=2.19 PyGithub~=1.55 -pyupgrade~=2.32 +pyupgrade~=2.34 yamllint~=1.26 From 9c094ea913aa0a77d0e3e99b07b2d664b207b51a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jun 2022 14:05:34 +0000 Subject: [PATCH 07/20] Bump actions/setup-python from 3 to 4 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/py-dead-code.yml | 2 +- .github/workflows/py-test.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/py-dead-code.yml b/.github/workflows/py-dead-code.yml index 91aabae..087dd1c 100644 --- a/.github/workflows/py-dead-code.yml +++ b/.github/workflows/py-dead-code.yml @@ -15,7 +15,7 @@ jobs: echo "package=$(ls -F | grep \/$ | grep -v "bin\|examples\|tests" | sed -n "s/\///g;1p")" >> $GITHUB_ENV - name: "Set up Python" - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: '3.9' diff --git a/.github/workflows/py-test.yml b/.github/workflows/py-test.yml index 7eabeb9..1f0bf89 100644 --- a/.github/workflows/py-test.yml +++ b/.github/workflows/py-test.yml @@ -23,7 +23,7 @@ jobs: echo "package=$(ls -F | grep \/$ | grep -v "bin\|examples\|tests" | sed -n "s/\///g;1p")" >> $GITHUB_ENV - name: "Set up Python" - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: '3.9' @@ -72,7 +72,7 @@ jobs: uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} From 26facb3f7089abb3a6dc5be9f09bd3a42686b5a3 Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Mon, 13 Jun 2022 18:13:01 +0300 Subject: [PATCH 08/20] Update component code imports --- .../integration_blueprint/__init__.py | 3 ++- .../integration_blueprint/binary_sensor.py | 5 +++-- .../integration_blueprint/config_flow.py | 8 ++------ custom_components/integration_blueprint/const.py | 15 ++++++++------- custom_components/integration_blueprint/sensor.py | 5 +++-- custom_components/integration_blueprint/switch.py | 5 +++-- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/custom_components/integration_blueprint/__init__.py b/custom_components/integration_blueprint/__init__.py index f75f03a..fcea637 100644 --- a/custom_components/integration_blueprint/__init__.py +++ b/custom_components/integration_blueprint/__init__.py @@ -9,6 +9,7 @@ from datetime import timedelta from homeassistant.config_entries import ConfigEntry +from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -16,7 +17,7 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from .api import IntegrationBlueprintApiClient -from .const import CONF_PASSWORD, CONF_USERNAME, DOMAIN, PLATFORMS, STARTUP_MESSAGE +from .const import DOMAIN, PLATFORMS, STARTUP_MESSAGE SCAN_INTERVAL = timedelta(seconds=30) diff --git a/custom_components/integration_blueprint/binary_sensor.py b/custom_components/integration_blueprint/binary_sensor.py index 813c454..4684cd3 100644 --- a/custom_components/integration_blueprint/binary_sensor.py +++ b/custom_components/integration_blueprint/binary_sensor.py @@ -1,8 +1,9 @@ """Binary sensor platform for integration_blueprint.""" from homeassistant.components.binary_sensor import BinarySensorEntity +from homeassistant.const import Platform from homeassistant.core import HomeAssistant -from .const import BINARY_SENSOR, BINARY_SENSOR_DEVICE_CLASS, DEFAULT_NAME, DOMAIN +from .const import BINARY_SENSOR_DEVICE_CLASS, DEFAULT_NAME, DOMAIN from .entity import IntegrationBlueprintEntity @@ -18,7 +19,7 @@ class IntegrationBlueprintBinarySensor(IntegrationBlueprintEntity, BinarySensorE @property def name(self): """Return the name of the binary_sensor.""" - return f"{DEFAULT_NAME}_{BINARY_SENSOR}" + return f"{DEFAULT_NAME}_{Platform.BINARY_SENSOR}" @property def device_class(self): diff --git a/custom_components/integration_blueprint/config_flow.py b/custom_components/integration_blueprint/config_flow.py index d96e842..2eedae1 100644 --- a/custom_components/integration_blueprint/config_flow.py +++ b/custom_components/integration_blueprint/config_flow.py @@ -4,17 +4,13 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.config_entries import ConfigEntry +from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.core import callback from homeassistant.helpers.aiohttp_client import async_create_clientsession from homeassistant.helpers.typing import ConfigType from .api import IntegrationBlueprintApiClient -from .const import ( # pylint: disable=unused-import - CONF_PASSWORD, - CONF_USERNAME, - DOMAIN, - PLATFORMS, -) +from .const import DOMAIN, PLATFORMS # pylint: disable=unused-import class BlueprintFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): diff --git a/custom_components/integration_blueprint/const.py b/custom_components/integration_blueprint/const.py index 33b66e8..62bf75d 100644 --- a/custom_components/integration_blueprint/const.py +++ b/custom_components/integration_blueprint/const.py @@ -1,8 +1,10 @@ """Constants for integration_blueprint.""" -# Base component constants from typing import Final +from homeassistant.const import Platform + +# Base component constants NAME: Final = "Integration blueprint" DOMAIN: Final = "integration_blueprint" VERSION: Final = "0.1.0" @@ -26,15 +28,14 @@ BINARY_SENSOR_DEVICE_CLASS: Final = "connectivity" # Platforms -BINARY_SENSOR: Final = "binary_sensor" -SENSOR: Final = "sensor" -SWITCH: Final = "switch" -PLATFORMS: Final = [BINARY_SENSOR, SENSOR, SWITCH] +PLATFORMS: Final = [ + Platform.BINARY_SENSOR, + Platform.SENSOR, + Platform.SWITCH, +] # Configuration and options CONF_ENABLED: Final = "enabled" -CONF_USERNAME: Final = "username" -CONF_PASSWORD: Final = "password" # Defaults DEFAULT_NAME: Final = DOMAIN diff --git a/custom_components/integration_blueprint/sensor.py b/custom_components/integration_blueprint/sensor.py index a8cb108..fb5c9a8 100644 --- a/custom_components/integration_blueprint/sensor.py +++ b/custom_components/integration_blueprint/sensor.py @@ -1,8 +1,9 @@ """Sensor platform for integration_blueprint.""" from homeassistant.components.sensor import SensorEntity +from homeassistant.const import Platform from homeassistant.core import HomeAssistant -from .const import DEFAULT_NAME, DOMAIN, ICON, SENSOR +from .const import DEFAULT_NAME, DOMAIN, ICON from .entity import IntegrationBlueprintEntity @@ -18,7 +19,7 @@ class IntegrationBlueprintSensor(IntegrationBlueprintEntity, SensorEntity): @property def name(self): """Return the name of the sensor.""" - return f"{DEFAULT_NAME}_{SENSOR}" + return f"{DEFAULT_NAME}_{Platform.SENSOR}" @property def native_value(self): diff --git a/custom_components/integration_blueprint/switch.py b/custom_components/integration_blueprint/switch.py index 2bc3108..c24c254 100644 --- a/custom_components/integration_blueprint/switch.py +++ b/custom_components/integration_blueprint/switch.py @@ -1,8 +1,9 @@ """Switch platform for integration_blueprint.""" from homeassistant.components.switch import SwitchEntity +from homeassistant.const import Platform from homeassistant.core import HomeAssistant -from .const import DEFAULT_NAME, DOMAIN, ICON, SWITCH +from .const import DEFAULT_NAME, DOMAIN, ICON from .entity import IntegrationBlueprintEntity @@ -28,7 +29,7 @@ async def async_turn_off(self, **kwargs): # pylint: disable=unused-argument @property def name(self): """Return the name of the switch.""" - return f"{DEFAULT_NAME}_{SWITCH}" + return f"{DEFAULT_NAME}_{Platform.SWITCH}" @property def icon(self): From 17d4fbc7cc05deb2169f2b7b12f066ec1a2f2c77 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jun 2022 14:10:07 +0000 Subject: [PATCH 09/20] Bump black from 22.3.0 to 22.6.0 Bumps [black](https://github.com/psf/black) from 22.3.0 to 22.6.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/22.3.0...22.6.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 8226a88..1651022 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ -r requirements-test.txt -black==22.3.0 +black==22.6.0 packaging==21.3 pre-commit~=2.19 PyGithub~=1.55 From 38a338f6880b46c2c4086bd7d3d80e495f0f8c50 Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Wed, 29 Jun 2022 21:58:17 +0300 Subject: [PATCH 10/20] Fix errors in tests --- .../integration_blueprint/config_flow.py | 2 +- pylintrc | 2 -- tests/const.py | 2 +- tests/test_config_flow.py | 17 ++++++++-------- tests/test_switch.py | 20 +++++++++++-------- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/custom_components/integration_blueprint/config_flow.py b/custom_components/integration_blueprint/config_flow.py index 2eedae1..3d41937 100644 --- a/custom_components/integration_blueprint/config_flow.py +++ b/custom_components/integration_blueprint/config_flow.py @@ -104,7 +104,7 @@ async def async_step_user(self, user_input: Optional[ConfigType] = None): step_id="user", data_schema=vol.Schema( { - vol.Required(x, default=self.options.get(x, True)): bool + vol.Required(str(x), default=self.options.get(str(x), True)): bool for x in sorted(PLATFORMS) } ), diff --git a/pylintrc b/pylintrc index 1369c36..ecb80d8 100644 --- a/pylintrc +++ b/pylintrc @@ -16,7 +16,6 @@ good-names=id,i,j,k,ex,Run,_,fp,T # locally-disabled - it spams too much # duplicate-code - unavoidable # cyclic-import - doesn't test if both import on load -# abstract-class-little-used - prevents from setting right foundation # unused-argument - generic callbacks and setup methods create a lot of warnings # too-many-* - are not enforced for the sake of readability # too-few-* - same as too-many-* @@ -26,7 +25,6 @@ good-names=id,i,j,k,ex,Run,_,fp,T # wrong-import-order - isort guards this disable= format, - abstract-class-little-used, abstract-method, cyclic-import, duplicate-code, diff --git a/tests/const.py b/tests/const.py index 380577e..dedcd41 100644 --- a/tests/const.py +++ b/tests/const.py @@ -1,7 +1,7 @@ """Constants for tests.""" from typing import Final -from custom_components.integration_blueprint.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.const import CONF_PASSWORD, CONF_USERNAME # Mock config data to be used across multiple tests MOCK_CONFIG: Final = {CONF_USERNAME: "test_username", CONF_PASSWORD: "test_password"} diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index f0c0bef..11934ca 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -5,16 +5,11 @@ import pytest from homeassistant import config_entries, data_entry_flow +from homeassistant.const import Platform from homeassistant.core import HomeAssistant from pytest_homeassistant_custom_component.common import MockConfigEntry -from custom_components.integration_blueprint.const import ( - BINARY_SENSOR, - DOMAIN, - PLATFORMS, - SENSOR, - SWITCH, -) +from custom_components.integration_blueprint.const import DOMAIN, PLATFORMS from .const import MOCK_CONFIG @@ -102,7 +97,7 @@ async def test_options_flow(hass: HomeAssistant): # Enter some fake data into the form result = await hass.config_entries.options.async_configure( result["flow_id"], - user_input={platform: platform != SENSOR for platform in PLATFORMS}, + user_input={platform: platform != Platform.SENSOR for platform in PLATFORMS}, ) # Verify that the flow finishes @@ -110,4 +105,8 @@ async def test_options_flow(hass: HomeAssistant): assert result["title"] == "test_username" # Verify that the options were updated - assert entry.options == {BINARY_SENSOR: True, SENSOR: False, SWITCH: True} + assert entry.options == { + Platform.BINARY_SENSOR: True, + Platform.SENSOR: False, + Platform.SWITCH: True, + } diff --git a/tests/test_switch.py b/tests/test_switch.py index 2210f3e..de9c542 100644 --- a/tests/test_switch.py +++ b/tests/test_switch.py @@ -1,10 +1,10 @@ # pylint: disable=protected-access,redefined-outer-name -"""Test integration_blueprint switch.""" +"""Test integration_blueprint Platform.SWITCH.""" from unittest.mock import call, patch from homeassistant.components.switch import SERVICE_TURN_OFF, SERVICE_TURN_ON -from homeassistant.const import ATTR_ENTITY_ID +from homeassistant.const import ATTR_ENTITY_ID, Platform from homeassistant.core import HomeAssistant from pytest_homeassistant_custom_component.common import MockConfigEntry @@ -12,13 +12,13 @@ IntegrationBlueprintApiClient, async_setup_entry, ) -from custom_components.integration_blueprint.const import DEFAULT_NAME, DOMAIN, SWITCH +from custom_components.integration_blueprint.const import DEFAULT_NAME, DOMAIN from .const import MOCK_CONFIG async def test_switch_services(hass: HomeAssistant, bypass_get_data): - """Test switch services.""" + """Test Platform.SWITCH services.""" # Create a mock entry so we don't have to go through config flow config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test") assert await async_setup_entry(hass, config_entry) @@ -28,9 +28,11 @@ async def test_switch_services(hass: HomeAssistant, bypass_get_data): # additional things, like whether a function was called or what arguments it was called with with patch.object(IntegrationBlueprintApiClient, "async_set_title") as title_func: await hass.services.async_call( - SWITCH, + Platform.SWITCH, SERVICE_TURN_OFF, - service_data={ATTR_ENTITY_ID: f"{SWITCH}.{DEFAULT_NAME}_{SWITCH}"}, + service_data={ + ATTR_ENTITY_ID: f"{Platform.SWITCH}.{DEFAULT_NAME}_{Platform.SWITCH}" + }, blocking=True, ) assert title_func.called @@ -39,9 +41,11 @@ async def test_switch_services(hass: HomeAssistant, bypass_get_data): title_func.reset_mock() await hass.services.async_call( - SWITCH, + Platform.SWITCH, SERVICE_TURN_ON, - service_data={ATTR_ENTITY_ID: f"{SWITCH}.{DEFAULT_NAME}_{SWITCH}"}, + service_data={ + ATTR_ENTITY_ID: f"{Platform.SWITCH}.{DEFAULT_NAME}_{Platform.SWITCH}" + }, blocking=True, ) assert title_func.called From 59ecff8a931fdc8f8b88921050c5b45302fb80b9 Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Wed, 29 Jun 2022 22:29:35 +0300 Subject: [PATCH 11/20] Add HA minimal version updating in hacs.json --- bin/update_manifest | 3 +++ hacs.json | 2 +- requirements.txt | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/update_manifest b/bin/update_manifest index 1478a66..43283a7 100755 --- a/bin/update_manifest +++ b/bin/update_manifest @@ -16,11 +16,13 @@ fi component=$(ls -q "${ROOT}/custom_components/" | grep -v __ | head -n 1) const_path="custom_components/${component}/const.py" +reqs_path="requirements.txt" name=$(grep "^NAME: Final =" ${const_path} | sed -E "s/^[^\"]+\"([^\"]*).*$/\\1/") domain=$(grep "^DOMAIN: Final =" ${const_path} | sed -E "s/^[^\"]+\"([^\"]*).*$/\\1/") version=$(grep "^VERSION: Final =" ${const_path} | sed -E "s/^[^\"]+\"([^\"]*).*$/\\1/") issue_url=$(grep "^ISSUE_URL: Final =" ${const_path} | sed -E "s/^[^\"]+\"([^\"]*).*$/\\1/") +ha_version=$(grep "^homeassistant>=" ${reqs_path} | sed -E "s/^[^=]+=(\S*).*$/\\1/") log.info "Update manifest.json data..." manifest_path="custom_components/${component}/manifest.json" @@ -32,3 +34,4 @@ sed -i -E "s!(\"issue_tracker\": \")[^\"]*!\\1${issue_url}!" ${manifest_path} log.info "Update hacs.json data..." hacs_path="${ROOT}/hacs.json" sed -i -E "s!(\"name\": \")[^\"]*!\\1${name}!" ${hacs_path} +sed -i -E "s!(\"homeassistant\": \")[^\"]*!\\1${ha_version}!" ${hacs_path} diff --git a/hacs.json b/hacs.json index 99ea29d..278a776 100644 --- a/hacs.json +++ b/hacs.json @@ -1,5 +1,5 @@ { "name": "Integration blueprint", "hacs": "1.6.0", - "homeassistant": "0.118.0" + "homeassistant": "2022.6.0" } diff --git a/requirements.txt b/requirements.txt index 444afaf..27ebdc2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -homeassistant>=2022.4 +homeassistant>=2022.6.0 From 128bd9b76b728b9ea5a7db46fb36f048bc4b7a74 Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Sat, 9 Jul 2022 23:09:49 +0300 Subject: [PATCH 12/20] Add manifests updating on every update of requirements.txt --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index be1cb4c..6f11119 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: name: Update manifest.json entry: bin/update_manifest language: script - files: ^custom_components/.+/const\.py$ + files: ^(custom_components/.+/const\.py|requirements\.txt)$ - repo: https://github.com/asottile/pyupgrade rev: v2.7.4 hooks: From b4e5f393478d48fee927cede562ef14e4b87d5f1 Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Sat, 9 Jul 2022 23:46:08 +0300 Subject: [PATCH 13/20] Fix release action --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 243e6e5..cf56e62 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,8 +7,8 @@ on: - "[v0-9]+.[0-9]+*" jobs: - release_zip_file: - name: "Prepare release asset" + release: + name: "Publish new release" runs-on: ubuntu-latest steps: - name: "Check out repository" @@ -17,7 +17,7 @@ jobs: - working-directory: ./custom_components run: | echo "package=$(ls -F | grep \/$ | sed -n "s/\///g;1p")" >> $GITHUB_ENV - echo "release_version=$(git describe --abbrev=0 | sed s/v//)" >> $GITHUB_ENV + echo "release_version=$(git describe --tags | sed s/v//)" >> $GITHUB_ENV - working-directory: ./custom_components run: | echo "basedir=$(pwd)/${{ env.package }}" >> $GITHUB_ENV From 475ca0634a864398f92af110a72ecdc5a0940ea2 Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Sun, 10 Jul 2022 00:04:33 +0300 Subject: [PATCH 14/20] Fix release action --- .github/workflows/release.yml | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf56e62..006aa91 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,6 +40,42 @@ jobs: with: files: ${{ env.basedir }}/${{ env.package }}.zip + release-notes: + name: "Compose release notes" + needs: release + runs-on: ubuntu-latest + steps: + - name: "Check out repository" + uses: actions/checkout@v3 + + - working-directory: ./custom_components + run: | + echo "release_version=$(git describe --tags | sed s/v//)" >> $GITHUB_ENV + + - name: "Set up Python" + if: env.release_version != '' && success() + uses: actions/setup-python@v3 + with: + python-version: 3.9 + + - name: "Cache pip" + if: env.release_version != '' && success() + uses: actions/cache@v3 + with: + # This path is specific to Ubuntu + path: ~/.cache/pip + # Look to see if there is a cache hit for the corresponding requirements file + key: ${{ runner.os }}-pip-${{ hashFiles('requirements*.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + ${{ runner.os }}- + + - name: "Install requirements" + if: env.release_version != '' && success() + run: | + python3 -m pip install setuptools wheel + python3 -m pip install -r ./requirements-dev.txt + - name: "Update release notes" if: env.release_version != '' && success() run: python3 ./bin/gen_releasenotes --token ${{ secrets.GITHUB_TOKEN }} --repo ${{ github.repository }} --release ${{ env.release_version }} From b8349becc92bf0a3fdb655bf6ac04c1667f50ad4 Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Sun, 10 Jul 2022 18:49:08 +0300 Subject: [PATCH 15/20] Add update requirements on update manifests --- bin/update_manifest | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/update_manifest b/bin/update_manifest index 43283a7..0e8f340 100755 --- a/bin/update_manifest +++ b/bin/update_manifest @@ -31,6 +31,8 @@ sed -i -E "s!(\"domain\": \")[^\"]*!\\1${domain}!" ${manifest_path} sed -i -E "s!(\"version\": \")[^\"]*!\\1${version}!" ${manifest_path} sed -i -E "s!(\"issue_tracker\": \")[^\"]*!\\1${issue_url}!" ${manifest_path} +bin/update_requirements + log.info "Update hacs.json data..." hacs_path="${ROOT}/hacs.json" sed -i -E "s!(\"name\": \")[^\"]*!\\1${name}!" ${hacs_path} From 6367c69f7c33f527ac3b888a068e8658e6d49ed3 Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Mon, 11 Jul 2022 02:41:54 +0300 Subject: [PATCH 16/20] Update update_requirements script --- bin/update_requirements | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/bin/update_requirements b/bin/update_requirements index abdf835..19902c5 100755 --- a/bin/update_requirements +++ b/bin/update_requirements @@ -34,29 +34,20 @@ for req in request: if "=" in req: harequire.append(get_package(req)) -print(harequire) - with open(f"{PKG_PATH}/manifest.json", encoding="utf8") as manifest: manifest = json.load(manifest) - requirements = [] - for req in manifest["requirements"]: - requirements.append(get_package(req)) - manifest["requirements"] = requirements + with open(f"{ROOT}/requirements.txt", encoding="utf8") as requirements: tmp = requirements.readlines() requirements = [] for req in tmp: requirements.append(req.replace("\n", "")) -for req in requirements: - pkg = get_package(req) - if pkg in manifest["requirements"]: - manifest["requirements"].remove(pkg) - manifest["requirements"].append(req) + manifest["requirements"] = requirements for req in manifest["requirements"]: pkg = get_package(req) if pkg in harequire: print(f"{pkg} in HA requirements, no need here.") -print(json.dumps(manifest["requirements"], indent=4)) + with open(f"{PKG_PATH}/manifest.json", "w", encoding="utf8") as manifestfile: manifestfile.write(json.dumps(manifest, indent=4)) From d91b5ebe510e063b7ecc6711aae022ab9bd4ba50 Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Mon, 11 Jul 2022 02:48:17 +0300 Subject: [PATCH 17/20] Update update_requirements script --- bin/update_requirements | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/bin/update_requirements b/bin/update_requirements index 19902c5..110099f 100755 --- a/bin/update_requirements +++ b/bin/update_requirements @@ -25,7 +25,7 @@ def get_package(requre: str) -> str: return requre.split(">")[0].split("<")[0].split("!")[0].split("=")[0].split("~")[0] -harequire = [] +harequire = ["homeassistant"] request = requests.get( "https://raw.githubusercontent.com/home-assistant/core/dev/requirements.txt" ) @@ -41,13 +41,10 @@ with open(f"{ROOT}/requirements.txt", encoding="utf8") as requirements: tmp = requirements.readlines() requirements = [] for req in tmp: - requirements.append(req.replace("\n", "")) + pkg = get_package(req) + if pkg not in harequire: + requirements.append(req.replace("\n", "")) manifest["requirements"] = requirements -for req in manifest["requirements"]: - pkg = get_package(req) - if pkg in harequire: - print(f"{pkg} in HA requirements, no need here.") - with open(f"{PKG_PATH}/manifest.json", "w", encoding="utf8") as manifestfile: manifestfile.write(json.dumps(manifest, indent=4)) From c331f7b2b8e3afff596ebcbd6f16402d2cb2e689 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Jul 2022 14:13:49 +0000 Subject: [PATCH 18/20] Update yamllint requirement from ~=1.26 to ~=1.27 Updates the requirements on [yamllint](https://github.com/adrienverge/yamllint) to permit the latest version. - [Release notes](https://github.com/adrienverge/yamllint/releases) - [Changelog](https://github.com/adrienverge/yamllint/blob/master/CHANGELOG.rst) - [Commits](https://github.com/adrienverge/yamllint/compare/v1.26.0...v1.27.1) --- updated-dependencies: - dependency-name: yamllint dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 1651022..fd5b21e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,4 +4,4 @@ packaging==21.3 pre-commit~=2.19 PyGithub~=1.55 pyupgrade~=2.34 -yamllint~=1.26 +yamllint~=1.27 From ce9210424fb3e2cdc85e34a9a897e3db620491bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Jul 2022 14:13:55 +0000 Subject: [PATCH 19/20] Update pre-commit requirement from ~=2.19 to ~=2.20 Updates the requirements on [pre-commit](https://github.com/pre-commit/pre-commit) to permit the latest version. - [Release notes](https://github.com/pre-commit/pre-commit/releases) - [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md) - [Commits](https://github.com/pre-commit/pre-commit/compare/v2.19.0...v2.20.0) --- updated-dependencies: - dependency-name: pre-commit dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 1651022..512b270 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,7 +1,7 @@ -r requirements-test.txt black==22.6.0 packaging==21.3 -pre-commit~=2.19 +pre-commit~=2.20 PyGithub~=1.55 pyupgrade~=2.34 yamllint~=1.26 From 07c14da46343a22bb51a69446d2eb49df22d8b06 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Jul 2022 11:35:17 +0000 Subject: [PATCH 20/20] Update pyupgrade requirement from ~=2.34 to ~=2.37 Updates the requirements on [pyupgrade](https://github.com/asottile/pyupgrade) to permit the latest version. - [Release notes](https://github.com/asottile/pyupgrade/releases) - [Commits](https://github.com/asottile/pyupgrade/compare/v2.34.0...v2.37.1) --- updated-dependencies: - dependency-name: pyupgrade dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 550494b..5f948de 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,5 +3,5 @@ black==22.6.0 packaging==21.3 pre-commit~=2.20 PyGithub~=1.55 -pyupgrade~=2.34 +pyupgrade~=2.37 yamllint~=1.27