### Start the server Source: https://gladysassistant.com/docs/dev/setup-development-environment-mac-linux Starts the Gladys Assistant server. ```bash npm start ``` -------------------------------- ### Start the server Source: https://gladysassistant.com/docs/dev/setup-development-environment-windows Starts the Gladys server. ```bash npm start ``` -------------------------------- ### Install system dependencies Source: https://gladysassistant.com/docs/dev/setup-development-environment-windows Installs necessary system libraries. ```bash sudo apt install sqlite3 make g++ git coreutils tzdata nmap openssl gzip udev -y ``` -------------------------------- ### Start server tests Source: https://gladysassistant.com/docs/dev/setup-development-environment-mac-linux Runs all server-side tests. ```bash npm test ``` -------------------------------- ### Install NPM dependencies (Frontend) Source: https://gladysassistant.com/docs/dev/setup-development-environment-windows Installs frontend NPM dependencies. ```bash cd front npm install ``` -------------------------------- ### Install Node.js 22 LTS on Ubuntu/Debian Source: https://gladysassistant.com/docs/dev/setup-development-environment-mac-linux Commands to download and run the NodeSource setup script, then install Node.js. ```bash curl -sLO https://deb.nodesource.com/nsolid_setup_deb.sh ``` ```bash sudo bash nsolid_setup_deb.sh 22 ``` ```bash sudo apt install nodejs -y ``` -------------------------------- ### Install NPM dependencies (Server) Source: https://gladysassistant.com/docs/dev/setup-development-environment-windows Installs server-side NPM dependencies. ```bash cd server npm install ``` -------------------------------- ### Start server tests Source: https://gladysassistant.com/docs/dev/setup-development-environment-windows Runs Mocha tests for the server. ```bash cd server npm test ``` -------------------------------- ### Start VSCode Source: https://gladysassistant.com/docs/dev/setup-development-environment-windows Launches Visual Studio Code from Ubuntu. ```bash code . ``` -------------------------------- ### Node.js 22 Installation Source: https://gladysassistant.com/docs/dev/setup-development-environment-windows Installs Node.js version 22. ```bash curl -sLO https://deb.nodesource.com/nsolid_setup_deb.sh sudo bash nsolid_setup_deb.sh 22 sudo apt install nodejs -y ``` -------------------------------- ### Start server tests for a single service Source: https://gladysassistant.com/docs/dev/setup-development-environment-windows Runs tests for a specific service. ```bash npm run test-service --service=tasmota ``` -------------------------------- ### Start Gladys Docker Container Source: https://gladysassistant.com/docs/installation/docker Command to start a Gladys Assistant Docker container with various configurations. ```bash sudo docker run -d \ --log-driver json-file \ --log-opt max-size=10m \ --cgroupns=host \ --restart=always \ --privileged \ --network=host \ --name gladys \ -e NODE_ENV=production \ -e SERVER_PORT=80 \ -e TZ=Europe/Paris \ -e SQLITE_FILE_PATH=/var/lib/gladysassistant/gladys-production.db \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /var/lib/gladysassistant:/var/lib/gladysassistant \ -v /dev:/dev \ -v /run/udev:/run/udev:ro \ gladysassistant/gladys:v4 ``` -------------------------------- ### Install NPM dependencies for the server Source: https://gladysassistant.com/docs/dev/setup-development-environment-mac-linux Installs the Node Package Manager dependencies for the server. ```bash npm install ``` -------------------------------- ### Start server tests for a specific service Source: https://gladysassistant.com/docs/dev/setup-development-environment-mac-linux Runs tests only for a specified service (e.g., 'tasmota'). ```bash npm run test-service --service=tasmota ``` -------------------------------- ### Install Docker Source: https://gladysassistant.com/docs/installation/docker Command to install Docker on a system. ```bash curl -sSL https://get.docker.com | sh ``` -------------------------------- ### Start Gladys Assistant Source: https://gladysassistant.com/docs/installation/docker-compose This command starts Gladys and Watchtower in detached mode. ```bash sudo docker compose -f gladys-compose.yml up -d ``` -------------------------------- ### Example index.js file for a service Source: https://gladysassistant.com/docs/dev/developing-a-service This is an example of an index.js file for a Gladys Assistant integration, demonstrating the structure for starting and stopping the service, and interacting with the Gladys API. ```javascript const logger = require("../../utils/logger"); const ExampleLightHandler = require("./lib/light"); module.exports = function ExampleService(gladys) { // here is an example module const axios = require("axios"); // @ts-ignore: TS doesn't know about the axios.create function const client = axios.create({ timeout: 1000, }); /** * @public * @description This function starts the ExampleService service * @example * gladys.services.example.start(); */ async function start() { logger.log("starting example service"); } /** * @public * @description This function stops the ExampleService service * @example * gladys.services.example.stop(); */ async function stop() { logger.log("stopping example service"); } return Object.freeze({ start, stop, device: new ExampleLightHandler(gladys, client), }); }; ``` -------------------------------- ### Start Gladys Source: https://gladysassistant.com/docs/installation/freebox-delta Command to launch Gladys using Docker. ```bash docker run -d \ --log-driver json-file \ --log-opt max-size=10m \ --cgroupns=host \ --restart=always \ --privileged \ --network=host \ --name gladys \ -e NODE_ENV=production \ -e SERVER_PORT=80 \ -e TZ=Europe/Paris \ -e SQLITE_FILE_PATH=/var/lib/gladysassistant/gladys-production.db \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /var/lib/gladysassistant:/var/lib/gladysassistant \ -v /dev:/dev \ -v /run/udev:/run/udev:ro \ gladysassistant/gladys:v4 ``` -------------------------------- ### Create .env file Source: https://gladysassistant.com/docs/dev/setup-development-environment-windows Creates a .env file with a specific configuration for silent service installation failures. ```bash echo "INSTALL_SERVICES_SILENT_FAIL=true" > .env ``` -------------------------------- ### Create .env file for silent service installation Source: https://gladysassistant.com/docs/dev/setup-development-environment-mac-linux Creates a .env file with INSTALL_SERVICES_SILENT_FAIL=true to prevent errors during development. ```bash echo "INSTALL_SERVICES_SILENT_FAIL=true" > .env ``` -------------------------------- ### Verify Docker Installation Source: https://gladysassistant.com/docs/installation/docker Command to verify Docker is working by checking for running containers. ```bash sudo docker ps ``` -------------------------------- ### Example package.json for a service Source: https://gladysassistant.com/docs/dev/developing-a-service This is an example of a package.json file for a Gladys Assistant integration, detailing its compatibility and dependencies. ```json { "name": "gladys-darksky", "main": "index.js", "os": ["darwin", "linux", "win32"], "cpu": ["x64", "arm", "arm64"], "scripts": {}, "dependencies": { "axios": "^0.18.0" } } ``` -------------------------------- ### Run DB migration Source: https://gladysassistant.com/docs/dev/setup-development-environment-windows Runs the database migration for development. ```bash npm run db-migrate:dev ``` -------------------------------- ### Run the linter Source: https://gladysassistant.com/docs/dev/setup-development-environment-mac-linux Executes the linter to check code style and quality. ```bash npm run eslint ``` -------------------------------- ### Run linter Source: https://gladysassistant.com/docs/dev/setup-development-environment-windows Runs the linter for the server code. ```bash npm run eslint ``` -------------------------------- ### Navigate to frontend directory Source: https://gladysassistant.com/docs/dev/setup-development-environment-mac-linux Changes the current directory to the frontend folder. ```bash cd front ``` -------------------------------- ### Run DB migration for development Source: https://gladysassistant.com/docs/dev/setup-development-environment-mac-linux Executes the database migration scripts for the development environment. ```bash npm run db-migrate:dev ``` -------------------------------- ### Auto-Upgrade Gladys with Watchtower Source: https://gladysassistant.com/docs/installation/docker Command to start a Watchtower container for automatic Gladys updates. ```bash sudo docker run -d \ --name watchtower \ --restart=always \ -v /var/run/docker.sock:/var/run/docker.sock \ nickfedor/watchtower \ --cleanup --include-restarting ``` -------------------------------- ### Auto-Upgrade Gladys with Watchtower Source: https://gladysassistant.com/docs/installation/freebox-delta Command to start a Watchtower container for automatic Gladys upgrades. ```bash docker run -d \ --name watchtower \ --restart=always \ -v /var/run/docker.sock:/var/run/docker.sock \ nickfedor/watchtower \ --cleanup --include-restarting ``` -------------------------------- ### WSL Configuration Source: https://gladysassistant.com/docs/dev/setup-development-environment-windows Ensures the system uses WSL2. ```bash wsl.exe --set-default-version 2 ``` -------------------------------- ### Clone Gladys Git repo Source: https://gladysassistant.com/docs/dev/setup-development-environment-windows Clones the Gladys Git repository and navigates into the directory. ```bash git clone https://github.com/GladysAssistant/Gladys gladys && cd gladys ``` -------------------------------- ### Example: Querying Coinbase API for Bitcoin Price Source: https://gladysassistant.com/docs/scenes/http-request An example demonstrating how to use an HTTP request to get the Bitcoin price from the Coinbase API and send it via Telegram. This snippet is described in prose and illustrated by a video, but no direct code is provided in the text. -------------------------------- ### Update distribution Source: https://gladysassistant.com/docs/dev/setup-development-environment-windows Updates the Ubuntu distribution. ```bash sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y ```