Giter VIP home page Giter VIP logo

homeremote's Introduction

HomeRemote

Web GUI in ES6 React for a Node backend that calls scripts spread out over several debian/ubuntu servers. The scripts are Upstart scripts to start/stop a radio playing service and direct shell calls to toggle a remote control for lightswitches.

Material Design:

Screenshot

Screenshot

Installation

Requirements:

  • Nginx/Traefik reverse proxy with SSL

  • Domoticz server (optional)

  • DataLora (optional)

  • WIP

Adding a user

  • This endpoint is only enabled in development mode
  • Start dev server: npm start
  • For password "test", call (e.g. in browser) http://localhost:4200/api/pw-to-hash/?password=test
  • Store the hash with the username in auth.json

Running

Development:

  • serve all: npm start or npx nx run-many --target=serve --projects=server,client --parallel

Other utils:

  • serve client: npx nx serve:all or npx nx serve client or npx nx run client:serve
  • Add an app (without e2e): npx nx g @nx/react:application --name=client --e2eTestRunner=none --dry-run or npx nx g @nx/nest:application --name=server --frontendProject=client --dry-run
  • Remove an app: npx nx g rm homeremote-server-e2e --dry-run
  • Move/rename an app: npx nx g mv --project homeremote client --dry-run
  • To build storybook run: npx nx run demo:build-storybook
  • Run lint on all projects: npx nx run-many --all --target=lint (with npx nx lint only the default project is linted) or for a specific project npx nx run server:lint
  • Testing:
    • with watch: npm run test:client or npx nx test client --watch
    • a single file without coverage and with watch, e.g. users.service: npm run test:server -- --testFile=users.service
  • Add a controller: npx nx g @nx/nest:controller --name=foo --project=server --module=app --dry-run
  • Format (prettier):
    • check changed: npx nx format:check
    • format changed: npx nx format:write
    • format all: npx nx format:write --all

Api proxying: server is running on 3333 and client on 4200, but a proxy.conf.json exists that forwards /api from 4200 to 3333.

env files: https://nx.dev/guides/environment-variables

Building / Run in production:

  • Install on Mac: python is on path, but can't be found by npm, even with npm config python. This makes the youtube-dl dependency installation fail when running npm i or npm i -f or even npm i --python=python3. For now, just remove youtube-dl on Mac from package.json, npm i, npm i youtube-dl@^3.5.0 --ignore-scripts
  • Python also failing Mac M1 and Ubuntu now. which python gives nothing, which python3 gives /usr/bin/python3. Symlink: ln -s /usr/bin/python3 /usr/bin/python
  • Optional: test building with npm run build
  • Make sure apps/server/.env and apps/server/auth.json exist
  • Set correct path for volumes in docker-compose.yml
  • When on Mac with Lima: disable docker.sock volume in docker-compose.yml (or try https://github.com/abiosoft/colima)
  • docker-compose up -d --build. Build duration: ca. 4 minutes
  • On Mac with colima use
  • Show logs: docker-compose logs --follow
  • Alternative, instead of docker compose (e.g. for debugging):
    • DOCKER_BUILDKIT=0 docker build -t homeremotenx . and
    • docker run --rm --name homeremotenx homeremotenx ls -lah dist/apps/server/src/assets/
  • If yarn install fails with timeouts on Mac with Lima compose (lima nerdctl compose up):

Publishing:

Publishing is done automatically when tagging on the main branch. So make sure to set up

  • secrets.DOCKER_USERNAME
  • secrets.DOCKER_PASSWORD
  1. Merge changes to main branch
  2. Update version in package.json to X.Y.Z, e.g. 3.0.0
  3. Tag with GitHub UI or with git tag -a vX.Y.Z -m "publish version X.Y.Z" and push git push --tags
  4. Wait for CI to finish, and all tests are OK. This will automatically build and push to the docker registry. To do this by hand, do this:
  • ONLY WHEN MANUAL: On dev machine, build image with correct version: docker build -t mdworld/homeremote:X.Y.Z . (on mac docker build --build-arg INSTALL_TIMEOUT="--network-timeout 1000000" -t mdworld/homeremote:X.Y.Z .)
  • ONLY WHEN MANUAL: On dev machine, push image to registry:
  1. On the target server, set up:
  • ~/homeremote/settings/auth (use apps/server/auth.json.example as base)
  • ~/homeremote/settings/.env (use apps/server/.env.example as base)
  • ~/homeremote/docker-compose.yml (copy docker-compose.yml from this project)
  1. Update the version in docker-compose.yml
  2. On the target server: docker-compose up -d

Generate types

  • Intercept a JSON to the intended endpoint, e.g. with cURL
  • Save the JSON in ./libs/types/examples. The internal subdir is for endpoints in this repo, the external subdir is for endpoints outside this repo, e.g. from third parties if they don't provide their own OpenApi descriptions.
  • Run npx mock-to-openapi ./libs/types/examples
  • Copy the generated snippet from ./libs/types/examples to the appropriate schema in ./libs/types/definitions
  • If there is no schema yet, this can be helpful to build one: https://editor.swagger.io/
  • Run npm run codegen
  • Types should be generated for the server and hooks for the client.

Notes

  • "noPropertyAccessFromIndexSignature": was turned to false when migrating, also see https://www.typescriptlang.org/tsconfig#noPropertyAccessFromIndexSignature

  • For Apple Silicon / ARM / Mac M1 there is an issue that the build will because it uses a platform specific version of @swc/core. Adding the ARM specific version @swc/core-darwin-arm64 breaks CI. Workaround to test the build locally is: docker build . -t mdworld/homeremote:latest --platform=linux/amd64

  • For Apple Silicon / ARM / Mac M1 with Colima, when Docker build fails with 'killed', try increasing available memory to 8GB with colima stop && colima start --cpu 2 --memory 8

Subsonic API_TOKEN

JUKEBOX_API_TOKEN is md5 of "subsonic password" + "some random salt"

FOO="$password$salt"

# Mac:
echo -n FOO | md5
# Linux:
echo -n FOO | md5sum

homeremote's People

Contributors

mdvanes avatar

Watchers

James Cloos avatar  avatar Jean-Laurent Girod avatar Kostas Georgiou avatar

homeremote's Issues

docker services

Show a list of (toggle?) buttons showing the state of (all?) docker services.

Provide as separate plugin.

Use ReasonML?

CEF log format

  • add WHO to log: CEF, Common Event Format, When Where Who What (only done for Monit controller)
  • Is the log persisted?

sc schedule

Show a schedule retrieved from an endpoint. Separate plugin, use Reason?

pihole

  • running/active?
  • up to date?
  • statistics

Nr of active connections

see ActiveConnections.tsx

Show the (number of) active connections to homeremote server, e.g. with meta data such as browser vendor, OS, username.

Only realistic option for web socket, because this is the only thing that the homeremote server really manages.
E.g. dockerlist or domoticz all have to poll their own back-end services. So they either use front-end polling or a web socket and then back-end polling.

Resources:

audio tag radio Elm

<audio controls>
  <source src="https://icecast.omroep.nl/radio2-bb-mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

Service workers is broken

Service workers is registered, but implementation of service-worker is incorrect / not caching when offline. Use Nx workers?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.