diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..bf50d6c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + groups: + GH actions: + dependency-type: production + - package-ecosystem: "npm" + directory: "/root/server" + schedule: + interval: "monthly" + groups: + npm: + dependency-type: production diff --git a/.github/workflows/addon-deploy.yaml b/.github/workflows/addon-deploy.yaml new file mode 100644 index 0000000..fb1e30f --- /dev/null +++ b/.github/workflows/addon-deploy.yaml @@ -0,0 +1,210 @@ +name: Deploy addon + +on: + workflow_call: + secrets: + DISPATCH_TOKEN: + required: true + +concurrency: + group: queue + +jobs: + information: + if: github.event_name == 'release' + name: โ„น๏ธ Gather add-on information + runs-on: ubuntu-latest + outputs: + architectures: ${{ steps.information.outputs.architectures }} + base_image_signer: ${{ steps.information.outputs.codenotary_base_image }} + build: ${{ steps.information.outputs.build }} + description: ${{ steps.information.outputs.description }} + environment: ${{ steps.release.outputs.environment }} + name: ${{ steps.information.outputs.name }} + signer: ${{ steps.information.outputs.codenotary_signer }} + slug: ${{ steps.override.outputs.slug }} + target: ${{ steps.information.outputs.target }} + version: ${{ steps.release.outputs.version }} + steps: + - name: โคต๏ธ Check out code from GitHub + uses: actions/checkout@v4 + + - name: ๐Ÿš€ Run add-on information action + id: information + uses: frenck/action-addon-information@v1.4.2 + + - name: โ„น๏ธ Gather version from GitHub + id: release + run: | + version="${{ github.event.release.tag_name }}" + version="${version,,}" + version="${version#v}" + + echo "version=${version}" >> "$GITHUB_OUTPUT" + + deploy: + name: ๐Ÿ‘ท Build & Deploy ${{ matrix.architecture }} + needs: information + runs-on: ubuntu-latest + strategy: + matrix: + architecture: ${{ fromJson(needs.information.outputs.architectures) }} + steps: + - name: โคต๏ธ Check out code from GitHub + uses: actions/checkout@v4 + - name: ๐Ÿ— Set up build cache + id: cache + uses: actions/cache@v4.0.2 + with: + path: /tmp/.docker-cache + key: docker-${{ matrix.architecture }}-${{ github.sha }} + restore-keys: | + docker-${{ matrix.architecture }} + - name: ๐Ÿ— Set up QEMU + uses: docker/setup-qemu-action@v3.2.0 + - name: ๐Ÿ— Set up Docker Buildx + uses: docker/setup-buildx-action@v3.6.1 + - name: โ„น๏ธ Compose build flags + id: flags + run: | + echo "date=$(date +"%Y-%m-%dT%H:%M:%SZ")" >> "$GITHUB_OUTPUT" + from=$(yq --no-colors eval ".build_from.${{ matrix.architecture }}" "${{ needs.information.outputs.build }}") + echo "from=${from}" >> "$GITHUB_OUTPUT" + + if [[ "${{ matrix.architecture}}" = "amd64" ]]; then + echo "platform=linux/amd64" >> "$GITHUB_OUTPUT" + elif [[ "${{ matrix.architecture }}" = "i386" ]]; then + echo "platform=linux/386" >> "$GITHUB_OUTPUT" + elif [[ "${{ matrix.architecture }}" = "armhf" ]]; then + echo "platform=linux/arm/v6" >> "$GITHUB_OUTPUT" + elif [[ "${{ matrix.architecture }}" = "armv7" ]]; then + echo "platform=linux/arm/v7" >> "$GITHUB_OUTPUT" + elif [[ "${{ matrix.architecture }}" = "aarch64" ]]; then + echo "platform=linux/arm64/v8" >> "$GITHUB_OUTPUT" + else + echo "::error ::Could not determine platform for architecture ${{ matrix.architecture }}" + exit 1 + fi + - name: ๐Ÿ— Login to GitHub Container Registry + uses: docker/login-action@v3.3.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: โคต๏ธ Download base image + if: steps.flags.outputs.from != 'null' + run: docker pull "${{ steps.flags.outputs.from }}" + - name: ๐Ÿš€ Build + uses: docker/build-push-action@v6.7.0 + with: + load: true + # yamllint disable rule:line-length + tags: | + ghcr.io/${{ github.repository_owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.environment }} + ghcr.io/${{ github.repository_owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.version }} + # yamllint enable rule:line-length + context: ${{ needs.information.outputs.target }} + file: ${{ needs.information.outputs.target }}/Dockerfile + cache-from: | + type=local,src=/tmp/.docker-cache + ghcr.io/${{ github.repository_owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:edge + cache-to: type=local,mode=max,dest=/tmp/.docker-cache-new + platforms: ${{ steps.flags.outputs.platform }} + build-args: | + BUILD_ARCH=${{ matrix.architecture }} + BUILD_DATE=${{ steps.flags.outputs.date }} + BUILD_DESCRIPTION=${{ needs.information.outputs.description }} + BUILD_FROM=${{ steps.flags.outputs.from }} + BUILD_NAME=${{ needs.information.outputs.name }} + BUILD_REF=${{ github.sha }} + BUILD_REPOSITORY=${{ github.repository }} + BUILD_VERSION=${{ needs.information.outputs.version }} + # This ugly bit is necessary, or our cache will grow forever... + # Well until we hit GitHub's limit of 5GB :) + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: ๐Ÿšš Swap build cache + run: | + rm -rf /tmp/.docker-cache + mv /tmp/.docker-cache-new /tmp/.docker-cache + - name: ๐Ÿš€ Push + # yamllint disable rule:line-length + run: | + docker push \ + "ghcr.io/${{ github.repository_owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.environment }}" + docker push \ + "ghcr.io/${{ github.repository_owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.version }}" + + publish-edge: + name: ๐Ÿ“ข Publish to edge repository + if: needs.information.outputs.environment == 'edge' + needs: + - information + - deploy + environment: + name: ${{ needs.information.outputs.environment }} + runs-on: ubuntu-latest + steps: + - name: ๐Ÿš€ Dispatch repository updater update signal + uses: peter-evans/repository-dispatch@v3.0.0 + with: + token: ${{ secrets.DISPATCH_TOKEN }} + repository: ${{ github.repository_owner }}/${{ inputs.repository_edge }} + event-type: update + client-payload: > + { + "addon": "${{ needs.information.outputs.slug }}", + "name": "${{ needs.information.outputs.name }}", + "repository": "${{ github.repository }}", + "version": "${{ needs.information.outputs.version }}" + } + + publish-beta: + name: ๐Ÿ“ข Publish to beta repository + if: | + needs.information.outputs.environment == 'beta' || + needs.information.outputs.environment == 'stable' + needs: + - information + - deploy + environment: + name: ${{ needs.information.outputs.environment }} + runs-on: ubuntu-latest + steps: + - name: ๐Ÿš€ Dispatch repository updater update signal + uses: peter-evans/repository-dispatch@v3.0.0 + with: + token: ${{ secrets.DISPATCH_TOKEN }} + repository: ${{ github.repository_owner }}/${{ inputs.repository_beta }} + event-type: update + client-payload: > + { + "addon": "${{ needs.information.outputs.slug }}", + "name": "${{ needs.information.outputs.name }}", + "repository": "${{ github.repository }}", + "version": "${{ github.event.release.tag_name }}" + } + + publish-stable: + name: ๐Ÿ“ข Publish to stable repository + if: needs.information.outputs.environment == 'stable' + needs: + - information + - deploy + environment: + name: ${{ needs.information.outputs.environment }} + runs-on: ubuntu-latest + steps: + - name: ๐Ÿš€ Dispatch repository updater update signal + uses: peter-evans/repository-dispatch@v3.0.0 + with: + token: ${{ secrets.DISPATCH_TOKEN }} + repository: ${{ github.repository_owner }}/${{ inputs.repository }} + event-type: update + client-payload: > + { + "addon": "${{ needs.information.outputs.slug }}", + "name": "${{ needs.information.outputs.name }}", + "repository": "${{ github.repository }}", + "version": "${{ github.event.release.tag_name }}" + } \ No newline at end of file diff --git a/.github/workflows/addon-main-push.yaml b/.github/workflows/addon-main-push.yaml new file mode 100644 index 0000000..5ac1e54 --- /dev/null +++ b/.github/workflows/addon-main-push.yaml @@ -0,0 +1,9 @@ +name: Draft release from new main push +on: + push: + branches: + - main + +jobs: + workflows: + uses: Poeschl-HomeAssistant-Addons/workflows/.github/workflows/release-drafter.yaml@main \ No newline at end of file diff --git a/.github/workflows/addon-pr.yaml b/.github/workflows/addon-pr.yaml new file mode 100644 index 0000000..261af64 --- /dev/null +++ b/.github/workflows/addon-pr.yaml @@ -0,0 +1,17 @@ +name: Check addon with linters +on: + push: + pull_request: + types: + - opened + - reopened + - synchronize + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + workflows: + uses: Poeschl-HomeAssistant-Addons/workflows/.github/workflows/addon-pr.yaml@main \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5a4addb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/data/options.json \ No newline at end of file diff --git a/.hadolint.yaml b/.hadolint.yaml new file mode 100644 index 0000000..db03439 --- /dev/null +++ b/.hadolint.yaml @@ -0,0 +1,2 @@ +ignored: + - DL3006 diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..268233a --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,10 @@ +default: true + +MD001: false # Heading levels should only increment by one level at a time +MD002: false # First header should be a h1 header +MD007: # Unordered list indentation + indent: 2 +MD012: false # Multiple consecutive blank lines +MD013: false # Line length +MD025: false # Multiple top level headings in the same document +MD041: false # First line in file should be a top level header \ No newline at end of file diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 0000000..6eccb2a --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1 @@ +disable=SC2002 diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..2bd2a2c --- /dev/null +++ b/.yamllint @@ -0,0 +1,37 @@ +--- +rules: + document-end: + level: error + present: false + document-start: + level: error + present: false + empty-lines: + level: error + max: 1 + max-start: 0 + max-end: 1 + hyphens: + level: error + max-spaces-after: 1 + indentation: + level: error + spaces: 2 + indent-sequences: true + check-multi-line-strings: false + key-duplicates: + level: error + line-length: + level: warning + max: 180 + allow-non-breakable-words: true + allow-non-breakable-inline-mappings: true + new-line-at-end-of-file: + level: error + new-lines: + level: error + type: unix + trailing-spaces: + level: error + truthy: + level: error \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..4d933e8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,228 @@ +## 4.0.0 - 2022-09-11 + +* ๐Ÿ”จ Changed OS from alpine to debian (glibc is now required) +* ๐Ÿ”ฅ Remove support for armhf architecture since [ICantBelieveItsNotValetudo does not support + it right now](https://github.com/Hypfer/ICantBelieveItsNotValetudo/issues/85) + +## 3.7.0 - 2022-07-28 + +* ๐Ÿ”ผ Updated ICantBelieveItsNotValetudo to latest release `2022.05.0` +* ๐Ÿ”ผ Update alpine to `3.16` +* ๐Ÿ”ผ Update git to `2.36.2-r0` +* ๐Ÿ”ผ Update npm to `8.10.0-r0` +* ๐Ÿ”ผ Update pixman/pixman-dev to `0.40.0-r3` +* ๐Ÿ”ผ Update pango/pango-dev to `1.50.7-r0` +* ๐Ÿ”ผ Update cairo/cairo-dev to `1.17.4-r2` +* ๐Ÿ”ผ Updated python3 to `3.10.5-r0` +* ๐Ÿ”ผ Updated build-base to `0.5-r3` +* ๐Ÿ”ผ Updated libjpeg-turbo/libjpeg-turbo-dev to `2.1.3-r1` +* ๐Ÿ”จ Migrated to S6-Overlay `V3` +* ๐Ÿ“ Updated to new repository structure + Yaml config + +## 3.6.2 - 2022-04-10 + +* ๐Ÿ“ Updated Readme + +## 3.6.1 - 2021-12-06 + +* โž• Add optional crop and padding settings + +## 3.6.0 - 2021-12-06 + +* ๐Ÿ”ผ Updated python3 to `3.9.5-r2` +* ๐Ÿ”ผ Updated ICantBelieveItsNotValetudo to latest release `2021.12.0` + +## 3.5.0 - 2021-10-31 + +* ๐Ÿ”ผ Updated ICantBelieveItsNotValetudo to latest release `2021.8.0` + +## 3.4.1 - 2021-07-27 + +* ๐Ÿ”ง Added port of mqtt broker to schema validaton +* ๐Ÿ”ผ Update alpine to `3.14` +* ๐Ÿ”ผ Update git to `2.32.0-r0` +* ๐Ÿ”ผ Update npm to `7.17.0-r0` +* ๐Ÿ”ผ Update pango/pango-dev to `1.48.5-r0` +* ๐Ÿ”ผ Update cairo/cairo-dev to `1.16.0-r3` +* ๐Ÿ”ผ Updated python3 to `3.9.5-r1` + +## 3.4.0 - 2021-06-20 + +* ๐Ÿ”ผ Updated ICantBelieveItsNotValetudo to latest release `2021.6.0` (thanks @ishioni) +* ๐Ÿ”ผ Updated python3 to `3.8.10-r0` + +## 3.3.1 - 2021-05-03 + +* ๐Ÿ”ผ Updated ICantBelieveItsNotValetudo default mqtt path, (@shalak) + + +## 3.3.0 - 2021-04-25 + +* ๐Ÿ”ผ Updated ICantBelieveItsNotValetudo to latest release `2021.4.0` +* ๐Ÿ”ผ Updated libjpeg-turbo/libjpeg-turbo-dev to `2.1.0-r0` +* ๐Ÿ”ผ Updated npm to `14.16.1-r1` + + +## 3.2.0 - 2021-04-02 + +* ๐Ÿ”ผ Updated ICantBelieveItsNotValetudo to latest release `2021.3.1` +* โž• Bring back the png image via webserver. + + +## 3.1.0 - 2021-04-02 + +* ๐Ÿ”จ Use ghcr.io/home-assistant for base images + + +## 3.0.1 - 2021-03-17 + +* ๐Ÿ› Specifiy own S6 entrypoint, don't rely on the base image. +* โž• Add optional `segments` color setting +* ๐Ÿ”ผ Update git to `2.30.2-r0` +* ๐Ÿ”ผ Updated python3 to `3.8.8-r0` + + +## 3.0.0 - 2021-02-27 + +* ๐Ÿ”ผ Updated ICantBelieveItsNotValetudo to latest commit `73a7965` to make it fully compatible with Valetudo > 2021.02.1 +* ๐Ÿ”ผ Updated npm to `14.16.0-r0` +* โž– Removed `homeassistantMapHack` notice + + +## 2.8.1 - 2021-02-20 + +* ๐Ÿ”ผ Updated python3 to `3.8.7-r1` +* ๐Ÿ”จ Changed the addon configuration to the current configuration of ICantBelieveItsNotValetudo (removing under/overlay images and cropping) +* โž• Add `homeassistantMapHack` notice +* โž– Removed `/share` mount + + +## 2.8.0 - 2021-02-18 + +* ๐Ÿ”ผ Updated ICantBelieveItsNotValetudo to latest commit `74b6c33` +* ๐Ÿ”ผ Updated npm to `14.15.5-r0` +* ๐Ÿ”จ Unspecify version of pkgconf +* โž– Removed webserver since [no image is served anymore](https://github.com/Hypfer/ICantBelieveItsNotValetudo/commit/54cc0d96a6c03ee4dc92b86e533c0cd3999a7068#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L14) +* โž– Removed ingress since not needed anymore, since nothing to serve + +### ๐Ÿ“Œ Note ๐Ÿ“Œ + +* No image will be served to the side panel anymore. The map is only available as mqtt camera. + + +## 2.7.0 - 2021-02-15 + +* ๐Ÿ”จ Allow also anonymous access in mqtt broker url +* ๐Ÿ”ผ Updated pango to `1.48.2-r0` + + +## 2.6.1 - 2021-02-10 + +* ๐Ÿ”ผ Updated git to `2.30.1-r0` + + +## 2.6.0 - 2021-01-30 + +* ๐Ÿ”ผ Updated alpine image to `3.13` +* ๐Ÿ”ผ Updated git to `2.30.0-r0` +* ๐Ÿ”ผ Updated npm to `14.15.4-r0` +* ๐Ÿ”ผ Updated python3 to `3.8.7-r0` +* ๐Ÿ”ผ Updated pkgconf to `1.7.3-r0` +* ๐Ÿ”ผ Updated pango/pango-dev to `1.48.1-r0` +* ๐Ÿ”ผ Updated libjpeg-turbo/libjpeg-turbo-dev to `2.0.6-r0` +* ๐Ÿ”จ Use Jemalloc for better memory handling + + +## 2.5.0 - 2020-12-14 + +* ๐Ÿ”จ Include small webserver to center the floorplan and apply the HA theme. +* ๐Ÿ”ผ Updated ICantBelieveItsNotValetudo to latest commit `bd687c1` + + +## 2.4.0 - 2020-11-28 + +* ๐Ÿ”ผ Updated ICantBelieveItsNotValetudo to latest commit `4b4a62c` + + +## 2.3.0 - 2020-10-23 + +* ๐Ÿ”ผ Updated ICantBelieveItsNotValetudo to latest commit `67f86e2` + +### โš ๏ธ Breaking Change โš ๏ธ + +* Colors are only supported as hex values. See [Colors](https://github.com/Hypfer/ICantBelieveItsNotValetudo#new-map-colors) +* Colors are not optional anymore, they will be set to the defaults if not existing. + +## 2.2.2 - 2020-10-22 + +* ๐Ÿ”จ Start as `application` startup type + +## 2.2.1 - 2020-10-06 + +* ๐Ÿ”ผ Updated npm to `12.18.4-r0` + +## 2.2.0 - 2020-07-29 + +* ๐Ÿ”ผ Updated ICantBelieveItsNotValetudo to latest commit `30945f9` to use the new map data format +* ๐Ÿ”ผ Updated alpine image to `3.12` +* ๐Ÿ”ผ Updated git to `2.26.2-r0` +* ๐Ÿ”ผ Updated npm to `12.17.0-r0` +* ๐Ÿ”จ Change build system to two-staged system for compiling needed npm packages outside of the running image +* ๐Ÿ”จ Use S6 system + +## 2.1.0 - 2020-05-29 + +* ๐Ÿ”ผ ๐Ÿ› Updated ICantBelieveItsNotValetudo to latest commit `9bcfc25` + +## 2.0.3 - 2020-05-22 + +* ๐Ÿ”จ Updated Changelog to new format + +## 2.0.2 - 2020-04-29 + +* ๐Ÿ”ผ Updated git to `2.24.3-r0` + +## 2.0.1 - 2020-04-16 + +* ๐Ÿ”ผ Updated git to `2.24.2-r0` + +## 2.0.0 - 2020-02-27 + +* ๐Ÿ”ผ Updated ICantBelieveItsNotValetudo to latest commit `3cf4f8a` +* โž• Adjusted to new config structure (__Make sure to migrate your existing config!__) + +## 1.0.0 - 2020-02-07 + +* โž• Own versioning for changes. Start with `1.0.0` +* ๐Ÿ”ผ Updated Dependencies: + * alpine `3.11` + * git `2.24.1-r0` + * npm `12.15.0-r1` + +## 0.2.0-5 - 2019-11-06 + +* โž• Added schema for optional cropping parameters + +## 0.2.0-4 - 2019-10-19 + +* ๐Ÿ”จ Switch to current master instead of latest version (thanks @Nickerchen) + +## 0.2.0-3 - 2019-10-15 + +* ๐Ÿ”ผ Use alpine 3.9 as base image + +## 0.2.0-2 - 2019-10-06 + +* ๐Ÿ”จ Integration into new build setup + +## 0.2.0-1 - 2019-09-02 + +* โž• Added HASS.io Ingress feature (#6) +* ๐Ÿ”จ Ingress is now the default access method + +## 0.2.0 - 2019-08-14 + +* โž• SSL Mapping on HASS.io +* โž• Add ICantBelieveItsNotValetudo Version 0.2.0 in its basic form +* โž• Added plugin to pre-built ones +* ๐Ÿ› Fixed MQTT config setting diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2b75c9d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,54 @@ +ARG BUILD_FROM +FROM $BUILD_FROM AS BUILD + +ENV LANG C.UTF-8 + +RUN apt-get update && apt-get -y --no-install-recommends install \ + git=1:2.35.1-1 \ + npm=8.19.2~ds1-2 \ + python3=3.10.6-1 \ + libpixman-1-dev=0.40.0-1 \ + libcairo2-dev=1.16.0-6 \ + libpango1.0-dev=1.50.10+ds-1 \ + build-essential=12.9 \ + libjpeg62-turbo-dev=1:2.1.2-1+b1 + +# Splited RUN for better layer caching +# hadolint ignore=DL3059 +RUN git config --global advice.detachedHead false && \ + git clone https://github.com/Hypfer/ICantBelieveItsNotValetudo.git -b 2022.05.0 /app + +WORKDIR /app +RUN npm install + + +FROM $BUILD_FROM AS SERVER + +RUN apt-get update && apt-get -y --no-install-recommends install \ + npm=8.19.2~ds1-2 + +COPY root/server /server + +WORKDIR /server +RUN npm install + + +FROM $BUILD_FROM AS RUNNING + +RUN apt-get update && apt-get -y --no-install-recommends install \ + npm=8.19.2~ds1-2 \ + libpixman-1-0=0.40.0-1 \ + libcairo2=1.16.0-6 \ + libpango-1.0-0=1.50.10+ds-1 \ + libjpeg62-turbo=1:2.1.2-1+b1 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +COPY --from=BUILD /app /app +COPY --from=SERVER /server /server + +ENTRYPOINT [ "/init" ] +CMD [] +COPY root / diff --git a/README.md b/README.md new file mode 100644 index 0000000..0a4729b --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# ICantBelieveItsNotValetudo Addon + +This is the adaption of [ICantBelieveItsNotValetudo](https://github.com/Hypfer/ICantBelieveItsNotValetudo) as a Supervisor addon. + +![Addon Stage][stage-badge] +![Supports aarch64 Architecture][aarch64-badge] +![Supports amd64 Architecture][amd64-badge] +![Supports armhf Architecture][armhf-badge] +![Supports armv7 Architecture][armv7-badge] +![Supports i386 Architecture][i386-badge] + +[![Add repository on my Home Assistant][repository-badge]][repository-url] +[![Install on my Home Assistant][install-badge]][install-url] +[![Donate][donation-badge]][donation-url] + +## Config + +The configuration keys are identical to the [configuration of ICantBelieveItsNotValetudo](https://github.com/Hypfer/ICantBelieveItsNotValetudo/blob/main/README.md). +Please get the meaning for them from there. +It's normal that the structure of the addon differs from the official config file, this is nessesary because of the Supervisor Addon config structure. + +If you use the Mosquitto Addon in Home Assistant `core-mosquitto` can be used as broker address like this: `mqtt://:@core-mosquitto`. Keep in mind to set proper `mapDataTopic` value. As of Valetudo 2021.04.0, it's `${topicPrefix}/${identifier}/MapData/map-data`, which with default values is equal to `valetudo/rockrobo/MapData/map-data`. + +## PNG image + +The generated image will be served over the Supervisor Ingress feature. So the floor plan can be accessed via the build-in side panel and the auto-configured mqtt camera. + +[aarch64-badge]: https://img.shields.io/badge/aarch64-yes-green.svg?style=for-the-badge +[amd64-badge]: https://img.shields.io/badge/amd64-yes-green.svg?style=for-the-badge +[armhf-badge]: https://img.shields.io/badge/armhf-no-red.svg?style=for-the-badge +[armv7-badge]: https://img.shields.io/badge/armv7-yes-green.svg?style=for-the-badge +[i386-badge]: https://img.shields.io/badge/i386-yes-green.svg?style=for-the-badge +[stage-badge]: https://img.shields.io/badge/Addon%20stage-stable-green.svg?style=for-the-badge +[install-badge]: https://img.shields.io/badge/Install%20on%20my-Home%20Assistant-41BDF5?logo=home-assistant&style=for-the-badge +[donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-%23d32f2f?logo=buy-me-a-coffee&style=for-the-badge&logoColor=white +[donation-url]: https://www.buymeacoffee.com/Poeschl +[repository-badge]: https://img.shields.io/badge/Add%20repository%20to%20my-Home%20Assistant-41BDF5?logo=home-assistant&style=for-the-badge + +[install-url]: https://my.home-assistant.io/redirect/supervisor_addon?addon=243ffc37_icantbelieveitsnotvaletudo +[repository-url]: https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2FPoeschl%2FHassio-Addons diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000..337046e --- /dev/null +++ b/build.yaml @@ -0,0 +1,5 @@ +build_from: + armv7: ghcr.io/home-assistant/armv7-base-debian:bookworm + aarch64: ghcr.io/home-assistant/aarch64-base-debian:bookworm + amd64: ghcr.io/home-assistant/amd64-base-debian:bookworm + i386: ghcr.io/home-assistant/i386-base-debian:bookworm diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..849573f --- /dev/null +++ b/config.yaml @@ -0,0 +1,71 @@ +name: ICantBelieveItsNotValetudo +version: 4.0.0 +slug: icantbelieveitsnotvaletudo +description: This is a simple companion service for valetudo which generates the map pngs. +url: https://github.com/Poeschl/Hassio-Addons/tree/main/ICantBelieveItsNotValetudo +arch: + - armv7 + - aarch64 + - amd64 + - i386 +image: ghcr.io/poeschl-homeAssistant-addons/icantbelieveitsnotvaletudo-{arch} +ports: + 8080/tcp: +ports_description: + 8080/tcp: Port serving the floor plan (Not required for Supervisor Ingress) +ingress: true +ingress_port: 8080 +panel_title: Valetudo Floorplan +panel_icon: mdi:floor-plan +init: false +map: + - ssl +schema: + mapSettings: + drawPath: bool + drawCharger: bool + drawRobot: bool + scale: int(0,) + rotate: int(0,) + crop_top: int(0,)? + crop_bottom: int(0,)? + crop_left: int(0,)? + crop_right: int(0,)? + padding_top: int(0,)? + padding_bottom: int(0,)? + padding_right: int(0,)? + padding_left: int(0,)? + mapColors: + floor: match(#(?:[0-9a-fA-F]{2}){2,4}$|(#[0-9a-fA-F]{3})$) + obstacle: match(#(?:[0-9a-fA-F]{2}){2,4}$|(#[0-9a-fA-F]{3})$) + path: match(#(?:[0-9a-fA-F]{2}){2,4}$|(#[0-9a-fA-F]{3})$) + segments: match(#(?:[0-9a-fA-F]{2}){2,4}$|(#[0-9a-fA-F]{3})$)? + mqtt: + identifier: str + topicPrefix: str + autoconfPrefix: str + broker_url: match(^mqtts?://(.+:.+@)?[^:@]+(:[0-9]+)?$) + caPath: str + mapDataTopic: str + minMillisecondsBetweenMapUpdates: int + publishMapImage: bool +options: + mapSettings: + drawPath: true + drawCharger: true + drawRobot: true + scale: 4 + rotate: 0 + mapColors: + floor: "#0076ff" + obstacle: "#52aeff" + path: "#ffffff" + mqtt: + identifier: rockrobo + topicPrefix: valetudo + autoconfPrefix: homeassistant + broker_url: mqtt://user:pass@foobar.example + caPath: "" + mapDataTopic: valetudo/rockrobo/MapData/map-data + minMillisecondsBetweenMapUpdates: 10000 + publishMapImage: true diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..5e0f976 Binary files /dev/null and b/icon.png differ diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..17a7485 Binary files /dev/null and b/logo.png differ diff --git a/root/app/config-template.jq b/root/app/config-template.jq new file mode 100644 index 0000000..f3585c4 --- /dev/null +++ b/root/app/config-template.jq @@ -0,0 +1,8 @@ +{ + "mapSettings": (.mapSettings + {"colors": (.mapColors // {})}), + "mqtt" : .mqtt, + "webserver": { + "enabled": true, + "port": 3000 + } +} diff --git a/root/etc/s6-overlay/s6-rc.d/ICantBelieveItsNotValetudo/producer-for b/root/etc/s6-overlay/s6-rc.d/ICantBelieveItsNotValetudo/producer-for new file mode 100644 index 0000000..8d31306 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/ICantBelieveItsNotValetudo/producer-for @@ -0,0 +1 @@ +Server diff --git a/root/etc/s6-overlay/s6-rc.d/ICantBelieveItsNotValetudo/run b/root/etc/s6-overlay/s6-rc.d/ICantBelieveItsNotValetudo/run new file mode 100644 index 0000000..e0befa7 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/ICantBelieveItsNotValetudo/run @@ -0,0 +1,10 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +set -e + +bashio::log.info 'Setup config' +jq -f /app/config-template.jq /data/options.json > /app/config.json + +bashio::log.info 'Start ICantBelieveItsNotValetudo' +cd /app +npm start diff --git a/root/etc/s6-overlay/s6-rc.d/ICantBelieveItsNotValetudo/type b/root/etc/s6-overlay/s6-rc.d/ICantBelieveItsNotValetudo/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/ICantBelieveItsNotValetudo/type @@ -0,0 +1 @@ +longrun diff --git a/root/etc/s6-overlay/s6-rc.d/Server/consumer-for b/root/etc/s6-overlay/s6-rc.d/Server/consumer-for new file mode 100644 index 0000000..e63a7f3 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/Server/consumer-for @@ -0,0 +1 @@ +ICantBelieveItsNotValetudo diff --git a/root/etc/s6-overlay/s6-rc.d/Server/run b/root/etc/s6-overlay/s6-rc.d/Server/run new file mode 100644 index 0000000..6fb0701 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/Server/run @@ -0,0 +1,7 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +set -e + +bashio::log.info 'Start Proxywebserver' +cd /server +npm start diff --git a/root/etc/s6-overlay/s6-rc.d/Server/type b/root/etc/s6-overlay/s6-rc.d/Server/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/Server/type @@ -0,0 +1 @@ +longrun diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/ICantBelieveItsNotValetudo b/root/etc/s6-overlay/s6-rc.d/user/contents.d/ICantBelieveItsNotValetudo new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/Server b/root/etc/s6-overlay/s6-rc.d/user/contents.d/Server new file mode 100644 index 0000000..e69de29 diff --git a/root/server/main.js b/root/server/main.js new file mode 100644 index 0000000..f9b754b --- /dev/null +++ b/root/server/main.js @@ -0,0 +1,46 @@ +const http = require('http'); +const request = require('request'); + +const index = ` + + + + + + + + + + +` + +http.createServer(function (req, resp) { + + var path = req.url; + + if (path == '/') { + resp.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'}); + resp.end(index, 'utf-8'); + + } else if (path == '/image') { + //Proxy to the original image + const mapImage = request('http://localhost:3000/api/map/image') + req.pipe(mapImage) + mapImage.pipe(resp) + + } else if (path == '/favicon.ico') { + //Ignore favicon + + } else { + console.warn('Invalid request ', path) + } +}).listen(8080); diff --git a/root/server/package.json b/root/server/package.json new file mode 100644 index 0000000..b8c1377 --- /dev/null +++ b/root/server/package.json @@ -0,0 +1,9 @@ +{ + "name": "valetudo-mini-server", + "dependencies": { + "request": "^2.88.2" + }, + "scripts": { + "start": "node main.js" + } +} \ No newline at end of file