From b5ae273a14b22cd19274c5f0822636f66bd98320 Mon Sep 17 00:00:00 2001 From: Stephen Moore Date: Sun, 20 Nov 2022 11:55:34 +1100 Subject: [PATCH] interactor: changing how the home assistant plugin works Pre-building the docker image is proving difficult and I'd rather it was using the hassio images. For now am replacing the prebuilt images with a Dockerfile in the addon repository --- .github/workflows/release-interactor.yml | 37 ++++++------------------ apps/interactor/docker/harpoon.yml | 8 ----- apps/interactor/docs/changelog.rst | 7 +++++ apps/interactor/docs/homeassistant.rst | 5 ++++ apps/interactor/interactor/server.py | 6 ++++ 5 files changed, 27 insertions(+), 36 deletions(-) diff --git a/.github/workflows/release-interactor.yml b/.github/workflows/release-interactor.yml index 9528a06d..bcd3b4cb 100644 --- a/.github/workflows/release-interactor.yml +++ b/.github/workflows/release-interactor.yml @@ -28,6 +28,7 @@ jobs: - run: python3 -m pip install venvstarter - name: Enable experimental features for the Docker daemon and CLI + if: github.event.inputs.skipdockermain == '0' run: | echo $'{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json mkdir -p ~/.docker @@ -42,12 +43,15 @@ jobs: - id: version run: | - printf "::set-output name=version::%s\n" $(python -c "import runpy; print(runpy.run_path('apps/interactor/interactor/__init__.py')['VERSION'])") - printf "::set-output name=versiondash::%s\n" $(python -c "import runpy; print(runpy.run_path('apps/interactor/interactor/__init__.py')['VERSION'].replace('.', '-'))") + version=$(python -c "import runpy; print(runpy.run_path('apps/interactor/interactor/__init__.py')['VERSION'])") + versiondash=$(python -c "import runpy; print(runpy.run_path('apps/interactor/interactor/__init__.py')['VERSION'].replace('.', '-'))") + + echo "version=$version" >> $GITHUB_OUTPUT + echo "versiondash=$versiondash" >> $GITHUB_OUTPUT - id: package run: > - printf "::set-output name=package::lifx-photons-interactor-${{ steps.version.outputs.version}}.tar.gz" + echo "package=lifx-photons-interactor-${{ steps.version.outputs.version}}.tar.gz" >> $GITHUB_OUTPUT - id: create_release uses: actions/create-release@v1 @@ -91,13 +95,6 @@ jobs: tar xf context_lifx-photons-interactor.tar rm context_lifx-photons-interactor.tar - cd .. - mkdir staging-homeassistant - cd staging-homeassistant - ../apps/interactor/docker/harpoon get_docker_context lifx-photons-interactor-homeassistant - tar xf context_lifx-photons-interactor-homeassistant.tar - rm context_lifx-photons-interactor-homeassistant.tar - - uses: docker/setup-qemu-action@v1 - uses: docker/setup-buildx-action@v1 @@ -106,10 +103,6 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - - id: repository_owner - run: | - printf "::set-output name=lowercase::%s\n" $(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]') - - name: Build and push uses: docker/build-push-action@v2 if: github.event.inputs.skipdockermain == '0' @@ -119,17 +112,5 @@ jobs: platforms: linux/386,linux/arm64,linux/amd64,linux/arm/v7,linux/arm/v6 push: true tags: | - ${{ steps.repository_owner.outputs.lowercase }}/lifx-photons-interactor:latest - ${{ steps.repository_owner.outputs.lowercase }}/lifx-photons-interactor:${{ steps.version.outputs.version }} - - - name: Build and push - uses: docker/build-push-action@v2 - if: github.event.inputs.skipdockerha == '0' - with: - context: staging-homeassistant - file: ./staging-homeassistant/Dockerfile - platforms: linux/386,linux/arm64,linux/amd64,linux/arm/v7,linux/arm/v6 - push: true - tags: | - ${{ steps.repository_owner.outputs.lowercase }}/lifx-photons-interactor-homeassistant:latest - ${{ steps.repository_owner.outputs.lowercase }}/lifx-photons-interactor-homeassistant:${{ steps.version.outputs.version }} + ${{ github.repository_owner }}/lifx-photons-interactor:latest + ${{ github.repository_owner }}/lifx-photons-interactor:${{ steps.version.outputs.version }} diff --git a/apps/interactor/docker/harpoon.yml b/apps/interactor/docker/harpoon.yml index f50fab4f..69b8d647 100644 --- a/apps/interactor/docker/harpoon.yml +++ b/apps/interactor/docker/harpoon.yml @@ -30,11 +30,3 @@ images: - ENV INTERACTOR_HOST 0.0.0.0 - HEALTHCHECK CMD lifx interactor_healthcheck --silent || exit 1 - CMD ["lifx", "lan:interactor"] - - lifx-photons-interactor-homeassistant: - context: false - - commands: - - [FROM, "delfick/lifx-photons-interactor:{VERSION:from_env}"] - - WORKDIR /data - - LABEL io.hass.version="0.8.5" io.hass.type="addon" io.hass.arch="aarch64|amd64|armhf|armv7|i386" diff --git a/apps/interactor/docs/changelog.rst b/apps/interactor/docs/changelog.rst index 84e684f3..4aa8c67b 100644 --- a/apps/interactor/docs/changelog.rst +++ b/apps/interactor/docs/changelog.rst @@ -3,6 +3,13 @@ Changelog ========= +.. _release-interactor-0-12-5: + +0.12.5 - TBD + * Added GET /v1/lifx/status that returns "working" + * Removed prebuilt homeassistant image and changed the plugin to offer + a Dockerfile that is built on installation instead + .. _release-interactor-0-12-4: 0.12.4 - 27 July 2022 diff --git a/apps/interactor/docs/homeassistant.rst b/apps/interactor/docs/homeassistant.rst index 3ef02e93..f4e510c2 100644 --- a/apps/interactor/docs/homeassistant.rst +++ b/apps/interactor/docs/homeassistant.rst @@ -32,3 +32,8 @@ Interactor do things to your devices: } Will use the interactor to change all of your lights to red. + +A custom lifx.yml configuration may also be provided by placing a ``lifx.yml`` +file in a ``photons`` folder in the home assistant ``config`` share. + +See https://www.home-assistant.io/docs/configuration/ diff --git a/apps/interactor/interactor/server.py b/apps/interactor/interactor/server.py index 2cbf3ff8..7378b4c2 100644 --- a/apps/interactor/interactor/server.py +++ b/apps/interactor/interactor/server.py @@ -18,6 +18,11 @@ REQUEST_IDENTIFIER_HEADER = "X-Request-ID" +class StatusHandler(tornado.web.RequestHandler): + def get(self): + self.write("working") + + class Commander(Commander): def peek_valid_request(self, meta, command, path, body): request = meta.everything["request_handler"].request @@ -138,6 +143,7 @@ def tornado_routes(self): "wsconnections": self.wsconnections, }, ), + ("/v1/lifx/status", StatusHandler), ] async def setup(self, server_options, *, tasks, sender, cleaners, animation_options=None):