From 1cca272a306eaa32737a4a31620f25a1e86e80d2 Mon Sep 17 00:00:00 2001 From: Minims Date: Mon, 20 Jan 2025 21:47:29 +0100 Subject: [PATCH] update: based on new addon example --- .devcontainer.json | 30 +++++---- .github/CODEOWNERS | 1 + .github/FUNDING.yml | 3 + .github/renovate.json | 62 +++++++++++++++++++ .github/workflows/deploy.yaml | 1 - MyFox2MQTT-dev/Dockerfile | 5 +- MyFox2MQTT-dev/translations/en.yaml | 1 + MyFox2MQTT/Dockerfile | 10 ++- MyFox2MQTT/translations/en.yaml | 1 + README.md | 2 + SomfyProtect2MQTT-dev/Dockerfile | 39 +++++++++--- SomfyProtect2MQTT-dev/build.yaml | 13 ++-- SomfyProtect2MQTT-dev/config.yaml | 4 +- .../s6-rc.d/SomfyProtect2MQTT/finish | 45 ++++++++++++++ .../s6-rc.d}/SomfyProtect2MQTT/run | 13 ++-- .../s6-overlay/s6-rc.d/SomfyProtect2MQTT/type | 1 + .../s6-rc.d/user/contents.d/SomfyProtect2MQTT | 0 .../etc/services.d/SomfyProtect2MQTT/finish | 12 ---- SomfyProtect2MQTT-dev/translations/en.yaml | 3 +- SomfyProtect2MQTT/Dockerfile | 10 ++- SomfyProtect2MQTT/build.yaml | 1 + SomfyProtect2MQTT/config.yaml | 4 +- SomfyProtect2MQTT/translations/en.yaml | 1 + 23 files changed, 192 insertions(+), 70 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/FUNDING.yml create mode 100644 .github/renovate.json create mode 100755 SomfyProtect2MQTT-dev/rootfs/etc/s6-overlay/s6-rc.d/SomfyProtect2MQTT/finish rename SomfyProtect2MQTT-dev/rootfs/etc/{services.d => s6-overlay/s6-rc.d}/SomfyProtect2MQTT/run (82%) create mode 100644 SomfyProtect2MQTT-dev/rootfs/etc/s6-overlay/s6-rc.d/SomfyProtect2MQTT/type create mode 100644 SomfyProtect2MQTT-dev/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/SomfyProtect2MQTT delete mode 100755 SomfyProtect2MQTT-dev/rootfs/etc/services.d/SomfyProtect2MQTT/finish diff --git a/.devcontainer.json b/.devcontainer.json index 08a5219..4d122bc 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -7,18 +7,22 @@ "containerEnv": { "WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}" }, - "extensions": ["timonwong.shellcheck", "esbenp.prettier-vscode"], - "mounts": ["type=volume,target=/var/lib/docker"], - "settings": { - "terminal.integrated.profiles.linux": { - "zsh": { - "path": "/usr/bin/zsh" + "customizations": { + "vscode": { + "extensions": ["timonwong.shellcheck", "esbenp.prettier-vscode"], + "settings": { + "terminal.integrated.profiles.linux": { + "zsh": { + "path": "/usr/bin/zsh" + } + }, + "terminal.integrated.defaultProfile.linux": "zsh", + "editor.formatOnPaste": false, + "editor.formatOnSave": true, + "editor.formatOnType": true, + "files.trimTrailingWhitespace": true } - }, - "terminal.integrated.defaultProfile.linux": "zsh", - "editor.formatOnPaste": false, - "editor.formatOnSave": true, - "editor.formatOnType": true, - "files.trimTrailingWhitespace": true - } + } + }, + "mounts": ["type=volume,target=/var/lib/docker"] } diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..4f91197 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +.github/* @minims \ No newline at end of file diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..256d753 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +--- +github: minims +custom: https://www.buymeacoffee.com/minims diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..10688a1 --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,62 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "rebaseWhen": "behind-base-branch", + "dependencyDashboard": true, + "labels": [ + "dependencies", + "no-stale" + ], + "commitMessagePrefix": "⬆️", + "commitMessageTopic": "{{depName}}", + "regexManagers": [ + { + "fileMatch": [ + "/Dockerfile$", + "/build.yaml$" + ], + "matchStringsStrategy": "any", + "matchStrings": [ + "ARG BUILD_FROM=(?.*?):(?.*?)\\s+", + "(aarch64|amd64|armv7):\\s[\"']?(?.*?):(?.*?)[\"']?\\s" + ], + "datasourceTemplate": "docker" + }, + { + "fileMatch": [ + "/Dockerfile$" + ], + "matchStringsStrategy": "any", + "matchStrings": [ + "\\s\\s(?[a-z0-9-]+)=(?[a-z0-9-_.]+)\\s+" + ], + "versioningTemplate": "loose", + "datasourceTemplate": "repology", + "depNameTemplate": "alpine_3_21/{{package}}" + } + ], + "packageRules": [ + { + "matchDatasources": [ + "repology" + ], + "automerge": true + }, + { + "groupName": "Add-on base image", + "matchDatasources": [ + "docker" + ] + }, + { + "groupName": "Add-on base image", + "matchDatasources": [ + "docker" + ], + "matchUpdateTypes": [ + "minor", + "patch" + ], + "automerge": true + } + ] +} \ No newline at end of file diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 9b224a5..21b20da 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -16,5 +16,4 @@ jobs: workflows: uses: hassio-addons/workflows/.github/workflows/addon-deploy.yaml@main secrets: - CAS_API_KEY: ${{ secrets.CAS_API_KEY }} DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }} diff --git a/MyFox2MQTT-dev/Dockerfile b/MyFox2MQTT-dev/Dockerfile index 8e4d467..348420c 100644 --- a/MyFox2MQTT-dev/Dockerfile +++ b/MyFox2MQTT-dev/Dockerfile @@ -1,6 +1,7 @@ # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile ARG BUILD_FROM FROM $BUILD_FROM +FROM $BUILD_FROM$:dev ENV LANG C.UTF-8 # Install required packages @@ -9,7 +10,7 @@ RUN pip3 install --no-cache-dir python-json2yaml==0.1.1 # Download source and untar WORKDIR /usr/bin -ADD "https://github.com/Minims/MyFox2MQTT/archive/refs/heads/dev.tar.gz" dev.tar.gz +COPY "https://github.com/Minims/MyFox2MQTT/archive/refs/heads/dev.tar.gz" dev.tar.gz RUN tar -xvf dev.tar.gz RUN mv /usr/bin/MyFox2MQTT-dev /usr/bin/MyFox2MQTT @@ -18,4 +19,4 @@ WORKDIR /usr/bin/MyFox2MQTT/myFox2Mqtt RUN pip3 install --no-cache-dir -r requirements.txt # Copy root filesystem -ADD rootfs / +COPY rootfs / diff --git a/MyFox2MQTT-dev/translations/en.yaml b/MyFox2MQTT-dev/translations/en.yaml index 70de024..9f92535 100644 --- a/MyFox2MQTT-dev/translations/en.yaml +++ b/MyFox2MQTT-dev/translations/en.yaml @@ -1,3 +1,4 @@ +--- configuration: message: name: Message diff --git a/MyFox2MQTT/Dockerfile b/MyFox2MQTT/Dockerfile index 64c0d0f..45df0de 100644 --- a/MyFox2MQTT/Dockerfile +++ b/MyFox2MQTT/Dockerfile @@ -1,18 +1,16 @@ # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile +ARG VERSION=2024.9.2 ARG BUILD_FROM -FROM $BUILD_FROM +FROM $BUILD_FROM:{$VERSION} ENV LANG C.UTF-8 -# MyFox2MQTT version -ARG VERSION=2024.9.2 - # Install required packages RUN apk add --no-cache py3-pip RUN pip3 install --no-cache-dir python-json2yaml==0.1.1 # Download source and untar WORKDIR /usr/bin -ADD "https://github.com/Minims/MyFox2MQTT/archive/refs/tags/${VERSION}.tar.gz" ${VERSION}.tar.gz +COPY "https://github.com/Minims/MyFox2MQTT/archive/refs/tags/${VERSION}.tar.gz" ${VERSION}.tar.gz RUN tar -xvf ${VERSION}.tar.gz RUN mv /usr/bin/MyFox2MQTT-${VERSION} /usr/bin/MyFox2MQTT @@ -21,4 +19,4 @@ WORKDIR /usr/bin/MyFox2MQTT/myFox2Mqtt RUN pip3 install --no-cache-dir -r requirements.txt # Copy root filesystem -ADD rootfs / +COPY rootfs / diff --git a/MyFox2MQTT/translations/en.yaml b/MyFox2MQTT/translations/en.yaml index 70de024..9f92535 100644 --- a/MyFox2MQTT/translations/en.yaml +++ b/MyFox2MQTT/translations/en.yaml @@ -1,3 +1,4 @@ +--- configuration: message: name: Message diff --git a/README.md b/README.md index 989fe21..6cceffb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/minims) + # Minims Home Assistant add-on repository [![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2FMinims%2Fhomeassistant-addons) diff --git a/SomfyProtect2MQTT-dev/Dockerfile b/SomfyProtect2MQTT-dev/Dockerfile index a1c4153..6a250d3 100644 --- a/SomfyProtect2MQTT-dev/Dockerfile +++ b/SomfyProtect2MQTT-dev/Dockerfile @@ -1,21 +1,40 @@ # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile ARG BUILD_FROM -FROM $BUILD_FROM +FROM ${BUILD_FROM}:dev ENV LANG C.UTF-8 -# Install required packages -RUN apk add --no-cache py3-pip py3-opencv ffmpeg -RUN pip3 install --no-cache-dir python-json2yaml==0.1.1 +# Copy root filesystem +COPY rootfs / + +# Setup base +RUN apk add --no-cache \ + build-base \ + ffmpeg \ + ffmpeg-dev \ + libjxl \ + libjxl-tools \ + libsrtp \ + libsrtp-dev \ + libvpx \ + libvpx-dev \ + openssl \ + openssl-dev \ + opus \ + opus-dev \ + py3-opencv \ + py3-pip \ + python3 \ + python3-dev \ + yq + +# Install python3 requirements +# RUN pip3 install --no-cache-dir python-json2yaml==0.1.1 # Download source and untar WORKDIR /usr/bin -ADD "https://github.com/Minims/SomfyProtect2MQTT/archive/refs/heads/dev.tar.gz" dev.tar.gz -RUN tar -xvf dev.tar.gz -RUN mv /usr/bin/SomfyProtect2MQTT-dev /usr/bin/SomfyProtect2MQTT +COPY "https://github.com/Minims/SomfyProtect2MQTT/archive/refs/heads/dev.tar.gz" dev.tar.gz +RUN tar -xvf dev.tar.gz && mv /usr/bin/SomfyProtect2MQTT-dev /usr/bin/SomfyProtect2MQTT # Install python3 requirements WORKDIR /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt RUN pip3 install --no-cache-dir -r requirements/addon.txt - -# Copy root filesystem -ADD rootfs / diff --git a/SomfyProtect2MQTT-dev/build.yaml b/SomfyProtect2MQTT-dev/build.yaml index 0a5ec77..fb01134 100644 --- a/SomfyProtect2MQTT-dev/build.yaml +++ b/SomfyProtect2MQTT-dev/build.yaml @@ -1,14 +1,15 @@ +--- # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile build_from: - aarch64: ghcr.io/hassio-addons/base:15.0.5 - amd64: ghcr.io/hassio-addons/base:15.0.5 - armhf: ghcr.io/hassio-addons/base:15.0.5 - armv7: ghcr.io/hassio-addons/base:15.0.5 - i386: ghcr.io/hassio-addons/base:15.0.5 + aarch64: ghcr.io/hassio-addons/base:17.1.0 + amd64: ghcr.io/hassio-addons/base:17.1.0 + armhf: ghcr.io/hassio-addons/base:17.1.0 + armv7: ghcr.io/hassio-addons/base:17.1.0 + i386: ghcr.io/hassio-addons/base:17.1.0 labels: org.opencontainers.image.title: "Home Assistant Add-on: Minims add-on" org.opencontainers.image.description: "Minims add-on to use as a blueprint for new add-ons." org.opencontainers.image.source: "https://github.com/Minims/homeassistant-addons" org.opencontainers.image.licenses: "Apache License 2.0" args: - VERSION: "2024.9.0" + VERSION: "2025.2.0a" diff --git a/SomfyProtect2MQTT-dev/config.yaml b/SomfyProtect2MQTT-dev/config.yaml index cc8a717..e8491f1 100644 --- a/SomfyProtect2MQTT-dev/config.yaml +++ b/SomfyProtect2MQTT-dev/config.yaml @@ -1,5 +1,5 @@ -# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config --- +# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config name: SomfyProtect2MQTT-dev version: dev slug: somfy-protect-2-mqtt-dev @@ -18,7 +18,7 @@ arch: init: false map: - share:rw - - config:rw + - homeassistant_config:rw options: somfy_protect: username: mail@example.org diff --git a/SomfyProtect2MQTT-dev/rootfs/etc/s6-overlay/s6-rc.d/SomfyProtect2MQTT/finish b/SomfyProtect2MQTT-dev/rootfs/etc/s6-overlay/s6-rc.d/SomfyProtect2MQTT/finish new file mode 100755 index 0000000..15e8bf4 --- /dev/null +++ b/SomfyProtect2MQTT-dev/rootfs/etc/s6-overlay/s6-rc.d/SomfyProtect2MQTT/finish @@ -0,0 +1,45 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== +# Home Assistant SomfyProtect2MQTT Add-on for Home Assistant +# ============================================================================== +declare exit_code +readonly exit_code_container=$( /run/s6-linux-init-container-results/exitcode + fi + + # If the signal is SIGTERM, we should halt the container and take down + # the whole process tree. + [[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt + +# The service exited with a non-zero exit code, which means it crashed. +elif [[ "${exit_code_service}" -ne 0 ]]; then + + # The service might be a result of another service crashing. Only + # overwrite the container exit code if it is not already set. + if [[ "${exit_code_container}" -eq 0 ]]; then + echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode + fi + + # We should halt the container and take down the whole process tree. + exec /run/s6/basedir/bin/halt + +# The service exited with a zero exit code, which means it exited, let +# S6 supervision restart it. +else + bashio::log.info "Service ${service} restarting..." +fi \ No newline at end of file diff --git a/SomfyProtect2MQTT-dev/rootfs/etc/services.d/SomfyProtect2MQTT/run b/SomfyProtect2MQTT-dev/rootfs/etc/s6-overlay/s6-rc.d/SomfyProtect2MQTT/run similarity index 82% rename from SomfyProtect2MQTT-dev/rootfs/etc/services.d/SomfyProtect2MQTT/run rename to SomfyProtect2MQTT-dev/rootfs/etc/s6-overlay/s6-rc.d/SomfyProtect2MQTT/run index 4349783..a340a40 100755 --- a/SomfyProtect2MQTT-dev/rootfs/etc/services.d/SomfyProtect2MQTT/run +++ b/SomfyProtect2MQTT-dev/rootfs/etc/s6-overlay/s6-rc.d/SomfyProtect2MQTT/run @@ -1,17 +1,14 @@ -#!/usr/bin/with-contenv bashio +#!/command/with-contenv bashio +# shellcheck shell=bash # ============================================================================== -# Start the example service -# s6-overlay docs: https://github.com/just-containers/s6-overlay +# Home Assistant Community Add-on: SomfyProtect2MQTT +# Runs SomfyProtect2MQTT # ============================================================================== -# Add your code here - -#!/usr/bin/env bashio - bashio::log.info "Generating config.yaml from options.json" echo '# Generated by homeassistant, do not edit!' > /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml.tmp echo '# Edit configuration only at the Add-on configuration tab!' >> /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml.tmp -json2yaml /data/options.json >> /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml.tmp +yq -P -oy /data/options.json >> /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml.tmp sed 's/ -/ -/' /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml.tmp > /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml bashio::log.info "Configuration :" bashio::log.info "$(cat /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt/config/config.yaml)" diff --git a/SomfyProtect2MQTT-dev/rootfs/etc/s6-overlay/s6-rc.d/SomfyProtect2MQTT/type b/SomfyProtect2MQTT-dev/rootfs/etc/s6-overlay/s6-rc.d/SomfyProtect2MQTT/type new file mode 100644 index 0000000..1780f9f --- /dev/null +++ b/SomfyProtect2MQTT-dev/rootfs/etc/s6-overlay/s6-rc.d/SomfyProtect2MQTT/type @@ -0,0 +1 @@ +longrun \ No newline at end of file diff --git a/SomfyProtect2MQTT-dev/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/SomfyProtect2MQTT b/SomfyProtect2MQTT-dev/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/SomfyProtect2MQTT new file mode 100644 index 0000000..e69de29 diff --git a/SomfyProtect2MQTT-dev/rootfs/etc/services.d/SomfyProtect2MQTT/finish b/SomfyProtect2MQTT-dev/rootfs/etc/services.d/SomfyProtect2MQTT/finish deleted file mode 100755 index d63c017..0000000 --- a/SomfyProtect2MQTT-dev/rootfs/etc/services.d/SomfyProtect2MQTT/finish +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bashio -# ============================================================================== -# Take down the S6 supervision tree when example fails -# s6-overlay docs: https://github.com/just-containers/s6-overlay -# ============================================================================== - -if [[ "$1" -ne 0 ]] && [[ "$1" -ne 256 ]]; then - bashio::log.warning "Halt add-on" - /run/s6/basedir/bin/halt -fi - -bashio::log.info "Service restart after closing" diff --git a/SomfyProtect2MQTT-dev/translations/en.yaml b/SomfyProtect2MQTT-dev/translations/en.yaml index 70de024..542b284 100644 --- a/SomfyProtect2MQTT-dev/translations/en.yaml +++ b/SomfyProtect2MQTT-dev/translations/en.yaml @@ -1,4 +1,5 @@ +--- configuration: message: name: Message - description: The message that will be printed to the log when starting this example add-on. + description: The message that will be printed to the log when starting this add-on. diff --git a/SomfyProtect2MQTT/Dockerfile b/SomfyProtect2MQTT/Dockerfile index dd7d3cd..c9c19c6 100644 --- a/SomfyProtect2MQTT/Dockerfile +++ b/SomfyProtect2MQTT/Dockerfile @@ -1,18 +1,16 @@ # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile +ARG VERSION=2024.9.0 ARG BUILD_FROM -FROM $BUILD_FROM +FROM $BUILD_FROM$:${VERSION} ENV LANG C.UTF-8 -# SomfyProtect2MQTT version -ARG VERSION=2024.9.0 - # Install required packages RUN apk add --no-cache py3-pip py3-opencv ffmpeg RUN pip3 install --no-cache-dir python-json2yaml==0.1.1 # Download source and untar WORKDIR /usr/bin -ADD "https://github.com/Minims/SomfyProtect2MQTT/archive/refs/tags/${VERSION}.tar.gz" ${VERSION}.tar.gz +COPY "https://github.com/Minims/SomfyProtect2MQTT/archive/refs/tags/${VERSION}.tar.gz" ${VERSION}.tar.gz RUN tar -xvf ${VERSION}.tar.gz RUN mv /usr/bin/SomfyProtect2MQTT-${VERSION} /usr/bin/SomfyProtect2MQTT @@ -21,4 +19,4 @@ WORKDIR /usr/bin/SomfyProtect2MQTT/somfyProtect2Mqtt RUN pip3 install --no-cache-dir -r requirements/addon.txt # Copy root filesystem -ADD rootfs / +COPY rootfs / diff --git a/SomfyProtect2MQTT/build.yaml b/SomfyProtect2MQTT/build.yaml index 0a5ec77..1e583d9 100644 --- a/SomfyProtect2MQTT/build.yaml +++ b/SomfyProtect2MQTT/build.yaml @@ -1,3 +1,4 @@ +--- # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile build_from: aarch64: ghcr.io/hassio-addons/base:15.0.5 diff --git a/SomfyProtect2MQTT/config.yaml b/SomfyProtect2MQTT/config.yaml index 5f306c3..80580ff 100644 --- a/SomfyProtect2MQTT/config.yaml +++ b/SomfyProtect2MQTT/config.yaml @@ -5,10 +5,8 @@ version: 2025.1.5 slug: somfy-protect-2-mqtt description: Publish Somfy Home Alarm as MQTT messages url: https://github.com/Minims/homeassistant-addons/tree/main/SomfyProtect2MQTT -startup: application services: - mqtt:need -boot: auto arch: - armhf - armv7 @@ -18,7 +16,7 @@ arch: init: false map: - share:rw - - config:rw + - homeassistant_config:rw options: somfy_protect: username: mail@example.org diff --git a/SomfyProtect2MQTT/translations/en.yaml b/SomfyProtect2MQTT/translations/en.yaml index 70de024..9f92535 100644 --- a/SomfyProtect2MQTT/translations/en.yaml +++ b/SomfyProtect2MQTT/translations/en.yaml @@ -1,3 +1,4 @@ +--- configuration: message: name: Message