From 584445b2ca1a7a982b08e2e286c4cfb11eb72ec2 Mon Sep 17 00:00:00 2001 From: Johannes Bauer Date: Wed, 5 Mar 2025 08:34:34 +0100 Subject: [PATCH 1/4] Add github actions --- .github/ISSUE_TEMPLATE/bug.yml | 54 ++++++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 1 + .github/ISSUE_TEMPLATE/feature_request.yml | 46 ++++++++++++++++++ .github/dependabot.yml | 15 ++++++ .github/workflows/lint.yml | 32 +++++++++++++ .github/workflows/validate.yml | 37 +++++++++++++++ .gitignore | 20 ++++++++ .ruff.toml | 26 +++++++++++ requirements.txt | 4 ++ 9 files changed, 235 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/validate.yml create mode 100644 .gitignore create mode 100644 .ruff.toml create mode 100644 requirements.txt diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..effbd36 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,54 @@ +--- +name: "Bug report" +description: "Report a bug with the integration" +body: +- type: markdown + attributes: + value: Before you open a new issue, search through the existing issues to see if others have had the same problem. +- type: textarea + attributes: + label: "System Health details" + description: "Paste the data from the System Health card in Home Assistant (https://www.home-assistant.io/more-info/system-health#github-issues)" + validations: + required: true +- type: checkboxes + attributes: + label: Checklist + options: + - label: I have enabled debug logging for my installation. + required: true + - label: I have filled out the issue template to the best of my ability. + required: true + - label: This issue only contains 1 issue (if you have multiple issues, open one issue for each issue). + required: true + - label: This issue is not a duplicate issue of any [previous issues](https://github.com/ludeeus/integration_blueprint/issues?q=is%3Aissue+label%3A%22Bug%22+).. + required: true +- type: textarea + attributes: + label: "Describe the issue" + description: "A clear and concise description of what the issue is." + validations: + required: true +- type: textarea + attributes: + label: Reproduction steps + description: "Without steps to reproduce, it will be hard to fix. It is very important that you fill out this part. Issues without it will be closed." + value: | + 1. + 2. + 3. + ... + validations: + required: true +- type: textarea + attributes: + label: "Debug logs" + description: "To enable debug logs check this https://www.home-assistant.io/integrations/logger/, this **needs** to include _everything_ from startup of Home Assistant to the point where you encounter the issue." + render: text + validations: + required: true + +- type: textarea + attributes: + label: "Diagnostics dump" + description: "Drag the diagnostics dump file here. (see https://www.home-assistant.io/integrations/diagnostics/ for info)" diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..ec4bb38 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..d424df6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,46 @@ +--- +name: "Feature request" +description: "Suggest an idea for this project" +body: +- type: markdown + attributes: + value: Before you open a new feature request, search through the existing feature requests to see if others have had the same idea. +- type: checkboxes + attributes: + label: Checklist + options: + - label: I have filled out the template to the best of my ability. + required: true + - label: This only contains 1 feature request (if you have multiple feature requests, open one feature request for each feature request). + required: true + - label: This issue is not a duplicate feature request of [previous feature requests](https://github.com/ludeeus/integration_blueprint/issues?q=is%3Aissue+label%3A%22Feature+Request%22+). + required: true + +- type: textarea + attributes: + label: "Is your feature request related to a problem? Please describe." + description: "A clear and concise description of what the problem is." + placeholder: "I'm always frustrated when [...]" + validations: + required: true + +- type: textarea + attributes: + label: "Describe the solution you'd like" + description: "A clear and concise description of what you want to happen." + validations: + required: true + +- type: textarea + attributes: + label: "Describe alternatives you've considered" + description: "A clear and concise description of any alternative solutions or features you've considered." + validations: + required: true + +- type: textarea + attributes: + label: "Additional context" + description: "Add any other context or screenshots about the feature request here." + validations: + required: true diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..04f2d40 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "weekly" + ignore: + # Dependabot should not update Home Assistant as that should match the homeassistant key in hacs.json + - dependency-name: "homeassistant" \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..0185a3e --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,32 @@ +name: "Lint" + +on: + push: + branches: + - "main" + pull_request: + branches: + - "main" + +jobs: + ruff: + name: "Ruff" + runs-on: "ubuntu-latest" + steps: + - name: "Checkout the repository" + uses: "actions/checkout@v4.2.2" + + - name: "Set up Python" + uses: actions/setup-python@v5.4.0 + with: + python-version: "3.13" + cache: "pip" + + - name: "Install requirements" + run: python3 -m pip install -r requirements.txt + + - name: "Lint" + run: python3 -m ruff check . + + - name: "Format" + run: python3 -m ruff format . --check diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..f00e169 --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,37 @@ +name: "Validate" + +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * *" + push: + branches: + - "main" + pull_request: + branches: + - "main" + +jobs: + hassfest: # https://developers.home-assistant.io/blog/2020/04/16/hassfest + name: "Hassfest Validation" + runs-on: "ubuntu-latest" + steps: + - name: "Checkout the repository" + uses: "actions/checkout@v4.2.2" + + - name: "Run hassfest validation" + uses: "home-assistant/actions/hassfest@master" + + hacs: # https://github.com/hacs/action + name: "HACS Validation" + runs-on: "ubuntu-latest" + steps: + - name: "Checkout the repository" + uses: "actions/checkout@v4.2.2" + + - name: "Run HACS validation" + uses: "hacs/action@main" + with: + category: "integration" + # Remove this 'ignore' key when you have added brand images for your integration to https://github.com/home-assistant/brands + ignore: "brands" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c7cc96e --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +.aider* + +# artifacts +__pycache__ +.pytest* +*.egg-info +*/build/* +*/dist/* + + +# misc +.coverage +.vscode +coverage.xml +.ruff_cache + + +# Home Assistant configuration +config/* +!config/configuration.yaml diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..8ea6a71 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,26 @@ +# The contents of this file is based on https://github.com/home-assistant/core/blob/dev/pyproject.toml + +target-version = "py312" + +[lint] +select = [ + "ALL", +] + +ignore = [ + "ANN101", # Missing type annotation for `self` in method + "ANN401", # Dynamically typed expressions (typing.Any) are disallowed + "D203", # no-blank-line-before-class (incompatible with formatter) + "D212", # multi-line-summary-first-line (incompatible with formatter) + "COM812", # incompatible with formatter + "ISC001", # incompatible with formatter +] + +[lint.flake8-pytest-style] +fixture-parentheses = false + +[lint.pyupgrade] +keep-runtime-typing = true + +[lint.mccabe] +max-complexity = 25 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..5af1d8b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +colorlog==6.9.0 +homeassistant==2025.2.4 +pip>=21.3.1 +ruff==0.9.9 \ No newline at end of file From 8dba1f119b51f2f94ce74cd98d81883c00b7a0e1 Mon Sep 17 00:00:00 2001 From: Johannes Bauer Date: Wed, 5 Mar 2025 09:32:16 +0100 Subject: [PATCH 2/4] Add iot_class in manifest.json --- custom_components/lambda_modbus/manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/lambda_modbus/manifest.json b/custom_components/lambda_modbus/manifest.json index 14c3d0b..bfe4d99 100644 --- a/custom_components/lambda_modbus/manifest.json +++ b/custom_components/lambda_modbus/manifest.json @@ -6,5 +6,6 @@ "dependencies": [], "codeowners": ["@johbau"], "config_flow": true, - "version": "0.6.1" + "version": "0.6.1", + "iot_class": "local_poll" } From ce0b8648009674700257d9f35b631022db45a569 Mon Sep 17 00:00:00 2001 From: Johannes Bauer Date: Wed, 5 Mar 2025 09:33:43 +0100 Subject: [PATCH 3/4] Fix iot_class --- custom_components/lambda_modbus/manifest.json | 2 +- hacs.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/lambda_modbus/manifest.json b/custom_components/lambda_modbus/manifest.json index bfe4d99..ce2fbf4 100644 --- a/custom_components/lambda_modbus/manifest.json +++ b/custom_components/lambda_modbus/manifest.json @@ -7,5 +7,5 @@ "codeowners": ["@johbau"], "config_flow": true, "version": "0.6.1", - "iot_class": "local_poll" + "iot_class": "local_polling" } diff --git a/hacs.json b/hacs.json index cdac10b..4401faa 100644 --- a/hacs.json +++ b/hacs.json @@ -3,5 +3,5 @@ "content_in_root": false, "domains": ["sensor"], "homeassistant": "2025.1.0", - "iot_class": "local_poll" + "iot_class": "local_polling" } From 8af6de86eb5b1d576af4e517bd3a88e1d70bdb95 Mon Sep 17 00:00:00 2001 From: Johannes Bauer Date: Wed, 5 Mar 2025 09:35:34 +0100 Subject: [PATCH 4/4] Sort keys alphabetically --- custom_components/lambda_modbus/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/lambda_modbus/manifest.json b/custom_components/lambda_modbus/manifest.json index ce2fbf4..1444121 100644 --- a/custom_components/lambda_modbus/manifest.json +++ b/custom_components/lambda_modbus/manifest.json @@ -2,10 +2,10 @@ "domain": "lambda_modbus", "name": "Lambda Modbus", "documentation": "https://github.com/johbau/home-assistant-lambda-modbus", + "iot_class": "local_polling", "requirements": ["pymodbus==3.7.4"], "dependencies": [], "codeowners": ["@johbau"], "config_flow": true, "version": "0.6.1", - "iot_class": "local_polling" }