diff --git a/Makefile b/Makefile deleted file mode 100644 index 8d9cd9d..0000000 --- a/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -BUILD_TAG=$(shell git describe --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g') -DC=BUILD_TAG=${BUILD_TAG} docker-compose -f docker-compose.build.yaml -f docker-compose.test.yaml - -build-with-builder: - docker run \ - --rm \ - --privileged \ - -v ~/.docker:/root/.docker \ - -v /var/run/docker.sock:/var/run/docker.sock:ro \ - -v ${PWD}:/data \ - homeassistant/amd64-builder \ - --amd64 \ - --test \ - --version ${BUILD_TAG} \ - -t /data - -build: - cd webapp && yarn build - $(DC) build - -build-no-cache: - cd webapp && yarn buil - $(DC) build --no-cache - -push: - $(DC) push - -start: - $(DC) up -d - sleep 1 - $(DC) ps - -logs: - $(DC) logs -f - -ps: - $(DC) ps - -stop: - $(DC) stop - -bash: - $(DC) exec addon bash - -config: - $(DC) config diff --git a/api/.env.api b/api/.env.api new file mode 100644 index 0000000..06931da --- /dev/null +++ b/api/.env.api @@ -0,0 +1,3 @@ +LOG_LEVEL=DEBUG +SUPERVISOR_TOKEN=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI2ZjJiYzM2MjkyOWM0OGM1Yjg1NzgxNDEzNTRkNDk0NSIsImlhdCI6MTY1OTExMTExMCwiZXhwIjoxOTc0NDcxMTEwfQ.Q5Ei1a9BXyB4-whrPGoko6CKavOOloFC1fbP-jAYBpU +HASSIO_WS=ws://homeassistant:8123/api/websocket diff --git a/api/.gitignore b/api/.gitignore index 4906f4c..8e84254 100644 --- a/api/.gitignore +++ b/api/.gitignore @@ -143,3 +143,4 @@ dmypy.json cython_debug/ # End of https://www.toptal.com/developers/gitignore/api/python +development_config \ No newline at end of file diff --git a/api/.vscode/extensions.json b/api/.vscode/extensions.json new file mode 100644 index 0000000..8ad5d9f --- /dev/null +++ b/api/.vscode/extensions.json @@ -0,0 +1,14 @@ +{ + "recommendations": [ + "njpwerner.autodocstring", + "bungcip.better-toml", + "ms-azuretools.vscode-docker", + "editorconfig.editorconfig", + "eamodio.gitlens", + "esbenp.prettier-vscode", + "ms-python.vscode-pylance", + "ms-python.python", + "redhat.vscode-yaml", + "ninoseki.vscode-pylens" + ] +} diff --git a/api/.vscode/tasks.json b/api/.vscode/tasks.json new file mode 100644 index 0000000..ecd70df --- /dev/null +++ b/api/.vscode/tasks.json @@ -0,0 +1,12 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "shell", + "label": "Docker: Server", + "group": "none", + "command": ["make start-docker"], + "problemMatcher": [] + } + ] +} diff --git a/api/Makefile b/api/Makefile index c318519..02ac608 100644 --- a/api/Makefile +++ b/api/Makefile @@ -40,7 +40,9 @@ clean: find . -type d -name "__pycache__" -exec rm -r {} + find . -type d -name "*tmp" -exec rm -r {} + -run-local: - rm -f web - ln -s ../webapp/build web - USE_EXAMPLE_REPO=1 $(VENV_BIN)/hypercorn src.app:app --reload +start-docker: + rm -rf ./development_config + tar -xvf ../development_config.tar.gz -C ./ + cp ./development_config/.env .env.api + docker-compose down + docker-compose up \ No newline at end of file diff --git a/api/README.md b/api/README.md index 0b7460d..b0c7426 100644 --- a/api/README.md +++ b/api/README.md @@ -8,4 +8,4 @@ `make lint`: run all linter and code formatting -`make run-local`: starts the api locally +`make start-docker`: starts the api locally diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml new file mode 100644 index 0000000..05e777c --- /dev/null +++ b/api/docker-compose.yaml @@ -0,0 +1,34 @@ +version: '3' +services: + homeassistant: + image: "ghcr.io/home-assistant/home-assistant:stable" + volumes: + - ./development_config/config:/config + restart: unless-stopped + networks: + - main + ports: + - 8124:8123 + addon: + image: "asosnovsky/shortumation-${ARCH:-amd64}:${BUILD_TAG:-edge}" + build: + context: "../" + dockerfile: "../Dockerfile" + args: + BUILD_ARCH: ${ARCH:-amd64} + BUILD_VERSION: ${BUILD_TAG:-edge} + volumes: + - "./development_config/config:/config" + - "./:/app" + - "../docker/bin:/app/bin" + - "../webapp/build:/app/web" + networks: + - main + ports: + - "8001:8000" + env_file: + - ./development_config/.env + entrypoint: hypercorn src.app:app --reload -b 0.0.0.0:8000 + +networks: + main: \ No newline at end of file diff --git a/development_config.tar.gz b/development_config.tar.gz new file mode 100644 index 0000000..0611540 Binary files /dev/null and b/development_config.tar.gz differ diff --git a/docker-compose.build.yaml b/docker-compose.build.yaml deleted file mode 100644 index c4c9093..0000000 --- a/docker-compose.build.yaml +++ /dev/null @@ -1,10 +0,0 @@ -version: '3' -services: - addon: - image: "asosnovsky/shortumation-${ARCH:-amd64}:${BUILD_TAG:-edge}" - build: - context: "./" - dockerfile: "./Dockerfile" - args: - BUILD_ARCH: ${ARCH:-amd64} - BUILD_VERSION: ${BUILD_TAG:-edge} diff --git a/docker-compose.test.yaml b/docker-compose.test.yaml deleted file mode 100644 index 3c74cc6..0000000 --- a/docker-compose.test.yaml +++ /dev/null @@ -1,10 +0,0 @@ -version: '3' -services: - addon: - volumes: - - "./sample_config:/config" - - "./api/tests:/app/tests" - ports: - - "8000:8000" - env_file: - - api/.env diff --git a/docker/bin/run.sh b/docker/bin/run.sh index 2890639..6ddf90a 100755 --- a/docker/bin/run.sh +++ b/docker/bin/run.sh @@ -9,6 +9,7 @@ pushd $api_location echo "--------------------" echo "BUILD_VERSION = "$BUILD_VERSION echo "HOST = $host_port" +echo "HASSIO_WS = $HASSIO_WS" echo $(python --version) echo "--------------------" python -m hypercorn src.app:app -b $host_port diff --git a/notes/logo.kra b/notes/logo.kra deleted file mode 100644 index 0d6343f..0000000 Binary files a/notes/logo.kra and /dev/null differ diff --git a/notes/logo.kra~ b/notes/logo.kra~ deleted file mode 100644 index 41599c5..0000000 Binary files a/notes/logo.kra~ and /dev/null differ diff --git a/notes/proto.drawio b/notes/proto.drawio deleted file mode 100644 index 6fb394c..0000000 --- a/notes/proto.drawio +++ /dev/null @@ -1 +0,0 @@ -7V1bk5s4Fv41rtp5aBfizmM6l9mZ7exkJpNN5qkLg2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lwC54rdAbN5Hb+vqqJWQ6B/b77AD6j3XUcry51xbfi+hC/JoLuWSasGlHkPC+lDYDVwf8gKXDH4CMuLupxz9t/hYTNOrAH8IZrPRO5vg30umvGPgVTZPLCTPNVOXM5h2af1kvYsxFWJapuuscsuZmpliLnPmppUBMl+wC3rLxEdZ8lX0JKOImUGhwEjDYSd2tVPhVoK7Z1sVzgVPTIGWxqnlVAuew+j1htAMQm2Vdecwj8LMOVskZuPalaso3gXtI1bosjtXMFye/ChYHnHxVy8IvjfSeGgnJrtOssdHatuTvz2uj3xznAQI6KbgDt5daTIex6b5hWIl/2VfrbWPrSYRXHSCkelrqkHr1TnAQb5kTU+uT2M30c5buvdx3HztDcDbCvTlPZH+gO1dW7nFH27KWlsHvL4D0knVToDjwQcM7S2obkwYL0vNzLYW1gLA+KpeTV84y+D4LD2H5VdGdQpBE6NzE/lOAmTPOzpIN827qTCeAr7g6PgO2HjVKVIJeZBg5+Yw3eR8XEFaVWViJeRa6cNUV+fw9ek56qIBIcQf9OA3DOpie/KPukFoDg9DH2HiV+VtiYJ3Mq+Bm3qRPZqQ1jQ54CD3X9OEhL0ji+KmYy9WFCU1tQNC9oOeUaagPZngdvMf2aps659Gcvk/ \ No newline at end of file diff --git a/sample_config/.shortumations/tags.yaml b/sample_config/.shortumations/tags.yaml deleted file mode 100644 index a972a80..0000000 --- a/sample_config/.shortumations/tags.yaml +++ /dev/null @@ -1,13 +0,0 @@ -0: - Type: Generic2 -1: - Type: Generic -2: - Type: Climate - Room: House -4: {} -3: - Type: Vent - Room: Bathroom - Floor: First -5: {} diff --git a/sample_config/automations.yaml b/sample_config/automations.yaml deleted file mode 100644 index 1cfde89..0000000 --- a/sample_config/automations.yaml +++ /dev/null @@ -1,66 +0,0 @@ -- id: '1616887975473' - alias: Home Assistant Off - description: '' - trigger_variables: - mode: single - trigger: - - platform: homeassistant - event: shutdown - - $smType: trigger - platform: device - device_id: '' - domain: '' - type: '' - subtype: '' - condition: [] - action: - - device_id: 2a98db84af7526c7ec3cc7aebd1a9e1c - domain: mobile_app - type: notify - title: Hassio Status - message: Hassio Is turning off... - - choose: [] - default: [] - alias: choose better days -- id: '1616888026264' - alias: Home Assistant On - description: '' - trigger_variables: - mode: single - trigger: - - platform: homeassistant - event: start - condition: [] - action: - - device_id: 2a98db84af7526c7ec3cc7aebd1a9e1c - domain: mobile_app - type: notify - title: Hassio Status - message: Home assistant is up! -- id: shortu-2 - alias: Neat trick - description: '' - mode: queued - trigger: [] - condition: [] - action: - - alias: Choose - default: - - condition: and - alias: '' - conditions: - - condition: or - conditions: [] - choose: [] - - service: lights.turn_on - target: - entity: bear - data: {} -- id: shortu-3 - alias: Bathroom Vent - description: Turn the vent on when the humidity is high or it's smelly - trigger_variables: - mode: single - trigger: [] - condition: [] - action: [] diff --git a/sample_config/configuration.yaml b/sample_config/configuration.yaml deleted file mode 100644 index 2707225..0000000 --- a/sample_config/configuration.yaml +++ /dev/null @@ -1,2 +0,0 @@ -# empty configuration file -cloud: diff --git a/webapp/.gitignore b/webapp/.gitignore index 448863b..f90c75b 100644 --- a/webapp/.gitignore +++ b/webapp/.gitignore @@ -21,4 +21,4 @@ npm-debug.log* yarn-debug.log* yarn-error.log* - +development_config diff --git a/webapp/.vscode/bin/start-docker-server.sh b/webapp/.vscode/bin/start-docker-server.sh new file mode 100755 index 0000000..b97bfa7 --- /dev/null +++ b/webapp/.vscode/bin/start-docker-server.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +BIN_DIR="$( realpath $( dirname -- "${BASH_SOURCE[0]}" ) )" +VSCODE_DIR="$( dirname ${BIN_DIR} )" +WEBAPP_DIR="$( dirname ${VSCODE_DIR} )" +ROOT_DIR="$( dirname ${WEBAPP_DIR} )" + +pushd $WEBAPP_DIR +rm -rf $WEBAPP_DIR/development_config +tar -xvf ../development_config.tar.gz -C $WEBAPP_DIR/ +docker-compose down +docker-compose up \ No newline at end of file diff --git a/webapp/.vscode/extensions.json b/webapp/.vscode/extensions.json new file mode 100644 index 0000000..a116c4c --- /dev/null +++ b/webapp/.vscode/extensions.json @@ -0,0 +1,13 @@ +{ + "recommendations": [ + "njpwerner.autodocstring", + "aeschli.vscode-css-formatter", + "paulmolluzzo.convert-css-in-js", + "ms-azuretools.vscode-docker", + "editorconfig.editorconfig", + "eamodio.gitlens", + "orta.vscode-jest", + "esbenp.prettier-vscode", + "pmneo.tsimporter" + ] +} diff --git a/webapp/.vscode/tasks.json b/webapp/.vscode/tasks.json index db0af2c..230d879 100644 --- a/webapp/.vscode/tasks.json +++ b/webapp/.vscode/tasks.json @@ -1,59 +1,74 @@ { - "version": "2.0.0", - "tasks": [ - { - "type": "npm", - "script": "tsc", - "problemMatcher": [], - "label": "npm: tsc", - "detail": "tsc -w", - "presentation": { - "reveal": "always", - "panel": "shared" - }, - "runOptions": { - "runOn": "folderOpen" - }, - "group": "test" - }, - { - "type": "npm", - "script": "test", - "problemMatcher": [], - "label": "npm: test", - "detail": "test", - "presentation": { - "reveal": "always", - "panel": "shared" - }, - "runOptions": { - "runOn": "folderOpen" - }, - "group": "test", - }, - { - "type": "npm", - "script": "storybook", - "problemMatcher": [], - "label": "npm: storybook", - "detail": "start-storybook -p 6006 -s public", - "promptOnClose": true - }, - { - "type": "npm", - "script": "build", - "problemMatcher": [], - "label": "npm: build", - "detail": "react-scripts build", - "group": "build" - }, - { - "type": "npm", - "script": "start", - "problemMatcher": [], - "label": "npm: start", - "detail": "react-scripts start", - "promptOnClose": true - }, - ] -} \ No newline at end of file + "version": "2.0.0", + "tasks": [ + { + "type": "shell", + "label": "Docker: Server", + "group": "none", + "command": [".vscode/bin/start-docker-server.sh"], + "runOptions": { + "runOn": "folderOpen" + } + }, + { + "type": "npm", + "script": "tsc", + "problemMatcher": [], + "label": "npm: tsc", + "detail": "tsc -w", + "presentation": { + "reveal": "always", + "panel": "shared" + }, + "runOptions": { + "runOn": "folderOpen" + }, + "group": "test" + }, + { + "type": "npm", + "script": "test", + "problemMatcher": [], + "label": "npm: test", + "detail": "test", + "presentation": { + "reveal": "always", + "panel": "shared" + }, + "runOptions": { + "runOn": "folderOpen" + }, + "group": "test" + }, + { + "type": "npm", + "script": "storybook", + "problemMatcher": [], + "label": "npm: storybook", + "detail": "start-storybook -p 6006 -s public", + "promptOnClose": true, + "runOptions": { + "runOn": "folderOpen" + } + }, + { + "type": "npm", + "script": "build", + "problemMatcher": [], + "label": "npm: build", + "detail": "react-scripts build", + "group": "build" + }, + { + "type": "npm", + "script": "start", + "problemMatcher": [], + "label": "npm: start", + "detail": "react-scripts start", + "promptOnClose": true, + "runOptions": { + "runOn": "folderOpen" + } + } + ] +} diff --git a/webapp/README.md b/webapp/README.md index d5537d3..f56070f 100644 --- a/webapp/README.md +++ b/webapp/README.md @@ -1,50 +1,19 @@ -## Available Scripts +# Development Guide -In the project directory, you can run: +## Prerequisites -### `yarn storybook` +- https://code.visualstudio.com/ +- https://nodejs.org/en/ +- https://www.docker.com/ -Spins up the prototyping tool storybook.\ -Open [http://localhost:6006](http://localhost:6006) to view it in the browser. +## Setup -The page will reload if you make edits.\ -You will also see any lint errors in the console. +Open this folder directly with vscode. As soon as it happens you will be prompted to install certain extensions and you should see a few tasks automatically spin up. Primarily: -### `yarn start` +- `npm: tsc`: scans code and validate the syntax is correct +- `npm: test`: automatically run test cases +- `npm: start`: automatically starts the webap on port `3000` +- `npm: storybook`: automatically starts storybook on port `6006` (I recommend you develop containers using this first!) +- `Docker: Server`: this will start the Shortumation server as well as a development Homeassistant container (you can access these over locahost:8123 and localhost:8000). -Runs the app in the development mode.\ -Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.\ -You will also see any lint errors in the console. - -### `yarn test` - -Launches the test runner in the interactive watch mode.\ -See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `yarn build` - -Builds the app for production to the `build` folder.\ -It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.\ -Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `yarn eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. - -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. - -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). +If you don't need some of these, you can turn them off by selecting the 'trash can' icon to their right. diff --git a/webapp/docker-compose.yaml b/webapp/docker-compose.yaml new file mode 100644 index 0000000..89b9c7d --- /dev/null +++ b/webapp/docker-compose.yaml @@ -0,0 +1,34 @@ +version: '3' +services: + homeassistant: + image: "ghcr.io/home-assistant/home-assistant:stable" + volumes: + - ./development_config/config:/config + restart: unless-stopped + networks: + - main + ports: + - 8123:8123 + addon: + image: "asosnovsky/shortumation-${ARCH:-amd64}:${BUILD_TAG:-edge}" + build: + context: "../" + dockerfile: "../Dockerfile" + args: + BUILD_ARCH: ${ARCH:-amd64} + BUILD_VERSION: ${BUILD_TAG:-edge} + volumes: + - "./development_config/config:/config" + - "../api:/app" + - "../docker/bin:/app/bin" + - "./build:/app/web" + networks: + - main + ports: + - "8000:8000" + env_file: + - ./development_config/.env + entrypoint: hypercorn src.app:app --reload -b 0.0.0.0:8000 + +networks: + main: \ No newline at end of file