diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml new file mode 100644 index 0000000..6cca9eb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -0,0 +1,59 @@ +--- +name: "Bug report" +description: "Report a bug with the integration" +labels: "Bug" +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 currently [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.yaml b/.github/ISSUE_TEMPLATE/config.yaml new file mode 100644 index 0000000..3ba13e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yaml @@ -0,0 +1 @@ +blank_issues_enabled: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml new file mode 100644 index 0000000..82e162a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -0,0 +1,49 @@ +--- +name: "Feature request" +description: "Suggest an idea for this project" +labels: "Feature+Request" +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..3f7fbb9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + target-branch: "staging" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/HACS.yml b/.github/workflows/HACS.yml deleted file mode 100644 index 8a27df1..0000000 --- a/.github/workflows/HACS.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: HACS Action - -on: - push: - pull_request: - # schedule: - # - cron: "0 0 * * mon" - -jobs: - hacs: - name: HACS Action - runs-on: "ubuntu-latest" - steps: - - name: HACS Action - uses: "hacs/action@main" - with: - category: "integration" diff --git a/.github/workflows/default_config.yaml b/.github/workflows/default_config.yaml new file mode 100644 index 0000000..1cbe9d3 --- /dev/null +++ b/.github/workflows/default_config.yaml @@ -0,0 +1,61 @@ +name: Update default_config + +on: + workflow_dispatch: + branches: + - main + push: + branches: + - main + schedule: + - cron: "0 0 * * *" + +concurrency: + group: "${{ github.workflow }}@${{ github.ref_name }}" + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + + permissions: write-all + + steps: + - name: "Checkout ${{ github.head_ref }}" + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + path: "clone" + + - name: "Checkout Git https://github.com/home-assistant/core/" + uses: actions/checkout@v3 + with: + repository: "home-assistant/core" + path: "upstream" + + - name: Update files via script + shell: bash + run: "clone/bin/update.sh" + + # - name: HACS Action + # uses: "hacs/action@main" + # with: + # category: "integration" + + # - name: Home Assistant 'hassfest' Action + # uses: "home-assistant/actions/hassfest@master" + + - uses: stefanzweifel/git-auto-commit-action@v4 + id: auto-commit-action + with: + repository: clone + + - name: Create Release + if: steps.auto-commit-action.outputs.changes_detected == 'true' + uses: ncipollo/release-action@v1.12.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + skipIfReleaseExists: true + tag: "${{ env.latest_tag }}" + name: "Release ${{ env.latest_tag }}" diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml new file mode 100644 index 0000000..37a9784 --- /dev/null +++ b/.github/workflows/dependabot.yml @@ -0,0 +1,21 @@ +name: Automerge Dependabot + +on: + pull_request: + pull_request_target: + branches: + - "staging" + +permissions: + id-token: write + contents: write + pull-requests: write + +jobs: + automerge-dependabot: + runs-on: ubuntu-latest + if: github.actor == 'dependabot[bot]' + steps: + - uses: fastify/github-action-merge-dependabot@v3 + with: + target: minor diff --git a/.github/workflows/hassfest.yml b/.github/workflows/hassfest.yml deleted file mode 100644 index 420390c..0000000 --- a/.github/workflows/hassfest.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Validate with hassfest - -on: - push: - pull_request: - # schedule: - # - cron: '0 0 * * mon' - -jobs: - validate: - runs-on: "ubuntu-latest" - steps: - - uses: "actions/checkout@v2" - - uses: "home-assistant/actions/hassfest@master" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9878844 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.history +cloud.code-workspace +upstream diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ba2eff7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "core"] + path = core + url = https://github.com/home-assistant/core diff --git a/bin/delete-workflow-run-history b/bin/delete-workflow-run-history new file mode 100755 index 0000000..4259dba --- /dev/null +++ b/bin/delete-workflow-run-history @@ -0,0 +1,4 @@ +#!/bin/bash +cd "$(dirname "$(dirname "${0}")")" || exit 1 +set -e -o pipefail +gh run list --limit 9999 --json databaseId -q '.[].databaseId' | xargs -IID gh api "repos/$(gh repo view --json nameWithOwner -q .nameWithOwner)/actions/runs/ID" -X DELETE --silent 2>/dev/null diff --git a/bin/update.sh b/bin/update.sh new file mode 100755 index 0000000..a8f6377 --- /dev/null +++ b/bin/update.sh @@ -0,0 +1,53 @@ +#!/bin/bash -x + +# Move to a known location and save as START_DIR. +cd "$(dirname "$(dirname "${0}")")" || exit 1 +START_DIR="${PWD}" + +# Ensure we exit if anything usingn a pipe ('|') fails. +set -e -o pipefail + +# Get the latest tag from the GitHub API. +HOME_ASSISTANT_CORE_LATEST_TAG="$(curl -Ls https://api.github.com/repos/home-assistant/core/tags | jq '.[].name' | sed 's/"//g' | grep -Ev '[[:alpha:]]' | sort -V | tail -n 1)" +if [[ -n "${GITHUB_ENV}" ]]; then + echo "latest_tag=${HOME_ASSISTANT_CORE_LATEST_TAG}" >>"$GITHUB_ENV" +fi + +# If we haven't already checked out the repo, do so now. +if [[ ! -d upstream ]]; then + + # Clone the repo max-depth of 1 commit as we only need the latest. + git clone --depth 1 https://github.com/home-assistant/core/ upstream + + # Ensure that the core directory gets cleaned up on exit. + trap "rm -rf "${START_DIR}/upstream"" EXIT + +fi + +# Create a variable for the source directory we are using. +SRC_DIR="${START_DIR}/upstream/homeassistant/components/default_config" + +# Check the source directory exists +test -d "${SRC_DIR}" || exit 1 + +# Create somewhere for our updated code to go. +if [[ ! -d custom_components/default_config ]]; then + mkdir -p custom_components/default_config +fi + +# Check for changed files +if [[ $(rsync -avz --checksum --dry-run ${START_DIR}/upstream/homeassistant/components/default_config ${START_DIR}/custom_components | grep -c default_config) -gt 1 ]]; then + + # Copy over the upstream files + rsync -avz "${START_DIR}/upstream/homeassistant/components/default_config" "${START_DIR}/custom_components" + + # Add in required data for the component to get loaded + cat <<<$(jq ". + { "version": \"${HOME_ASSISTANT_CORE_LATEST_TAG}.1\" }" ${START_DIR}/custom_components/default_config/manifest.json) >${START_DIR}/custom_components/default_config/manifest.json + + # Disable the 'cloud' integration. + cat <<<$(jq 'del(.dependencies[] | select(. == "cloud"))' ${START_DIR}/custom_components/default_config/manifest.json) >${START_DIR}/custom_components/default_config/manifest.json + + # Update hacs.json with the minimum homeassistant value for the latest release + cat <<<$(jq ".homeassistant = \"${HOME_ASSISTANT_CORE_LATEST_TAG}\"" ${START_DIR}/hacs.json) >${START_DIR}/hacs.json + +fi diff --git a/custom_components/cloud/__init__.py b/custom_components/cloud/__init__.py deleted file mode 100755 index 04791b2..0000000 --- a/custom_components/cloud/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -"""Cloud.""" -DOMAIN = "cloud" - -def setup(hass, config): - - # Return boolean to indicate that initialization was successful. - return True \ No newline at end of file diff --git a/custom_components/cloud/manifest.json b/custom_components/cloud/manifest.json deleted file mode 100755 index 10ba1a3..0000000 --- a/custom_components/cloud/manifest.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "domain": "cloud", - "name": "Cloud Hider", - "documentation": "https://github.com/benquan/cloud", - "issue_tracker": "https://github.com/benquan/cloud/issues", - "codeowners": ["@benquan"], - "dependencies": [], - "requirements": [], - "integration_type": "system", - "iot_class": "assumed_state", - "version": "1.0" - } diff --git a/custom_components/default_config/__init__.py b/custom_components/default_config/__init__.py new file mode 100644 index 0000000..25a9ca3 --- /dev/null +++ b/custom_components/default_config/__init__.py @@ -0,0 +1,18 @@ +"""Component providing default configuration for new users.""" +from homeassistant.components.hassio import is_hassio +from homeassistant.core import HomeAssistant +from homeassistant.helpers import config_validation as cv +from homeassistant.helpers.typing import ConfigType +from homeassistant.setup import async_setup_component + +DOMAIN = "default_config" + +CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN) + + +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: + """Initialize default configuration.""" + if not is_hassio(hass): + await async_setup_component(hass, "backup", config) + + return True diff --git a/custom_components/default_config/manifest.json b/custom_components/default_config/manifest.json new file mode 100644 index 0000000..e117b9f --- /dev/null +++ b/custom_components/default_config/manifest.json @@ -0,0 +1,52 @@ +{ + "domain": "default_config", + "name": "Default Config", + "codeowners": [ + "@home-assistant/core" + ], + "dependencies": [ + "application_credentials", + "assist_pipeline", + "automation", + "bluetooth", + "conversation", + "counter", + "dhcp", + "energy", + "frontend", + "hardware", + "history", + "homeassistant_alerts", + "input_boolean", + "input_button", + "input_datetime", + "input_number", + "input_select", + "input_text", + "logbook", + "logger", + "map", + "media_source", + "mobile_app", + "my", + "network", + "person", + "scene", + "schedule", + "script", + "ssdp", + "stream", + "sun", + "system_health", + "tag", + "timer", + "usb", + "webhook", + "zeroconf", + "zone" + ], + "documentation": "https://www.home-assistant.io/integrations/default_config", + "integration_type": "system", + "quality_scale": "internal", + "version": "2023.12.0.1" +} diff --git a/hacs.json b/hacs.json index a74a7d3..52c460a 100644 --- a/hacs.json +++ b/hacs.json @@ -1,4 +1,5 @@ { - "name": "Home Assistant Cloud Hider", - "render_readme": true -} \ No newline at end of file + "name": "Home Assistant Cloud Hider", + "render_readme": true, + "homeassistant": "2023.12.0" +}