### Install and Serve Scrypted Source: https://github.com/koush/scrypted/wiki/Local-Installation-(Advanced) Use npx to install and start the Scrypted server. This command also handles the initial installation to your home directory. ```shell # node should come with "npx". # install and start the scrypted server npx -y scrypted serve ``` -------------------------------- ### Run Scrypted Example with ts-node Source: https://github.com/koush/scrypted/blob/main/packages/client/README.md Install ts-node globally and then execute the example TypeScript file. This is a common way to run standalone TypeScript scripts. ```bash npm -g install ts-node ts-node examples/example.ts ``` -------------------------------- ### Install Node.js on Device Source: https://github.com/koush/scrypted/blob/main/plugins/bticino/README.md Steps to download, extract, and verify the installation of Node.js v17.9.1 on the device. ```bash cd /home/bticino/cfg/extra/ mkdir node cd node wget https://nodejs.org/download/release/latest-v17.x/node-v17.9.1-linux-armv7l.tar.gz tar xvfz node-v17.9.1-linux-armv7l.tar.gz ``` ```bash root@C3X-00-00-00-00-00--2222222:~# /home/bticino/cfg/extra/node/bin/node -v v17.9.1 ``` -------------------------------- ### Download and Install Scrypted Docker Compose Script Source: https://github.com/koush/scrypted/wiki/Installation:-Docker-Compose-Linux Execute this script to download dependencies, Docker, and install Scrypted as a service. It sets the user for the service and installs Scrypted into ~/.scrypted. ```bash mkdir -p ~/.scrypted curl -s https://raw.githubusercontent.com/koush/scrypted/main/install/docker/install-scrypted-docker-compose.sh > ~/.scrypted/install-scrypted-docker-compose.sh sudo SERVICE_USER=$USER bash ~/.scrypted/install-scrypted-docker-compose.sh ``` -------------------------------- ### Install Docker using Convenience Script Source: https://github.com/koush/scrypted/wiki/Installing-Docker-(Linux) Run these commands in your terminal to download and execute the Docker installation script. It's recommended to add your user to the 'docker' group for easier access and reboot afterward. ```bash curl -fsSL https://get.docker.com -o get-docker.sh sh get-docker.sh # add current user to docker group sudo usermod -aG docker $USER newgrp docker # reboot your server to ensure system changes take effect ``` -------------------------------- ### Start Docker Service on Ubuntu (WSL2) Source: https://github.com/koush/scrypted/wiki/Installation:-WSL2-Windows Starts the Docker service within your WSL2 Ubuntu distribution. This command is necessary for Docker to function. ```bash sudo service docker start ``` -------------------------------- ### Install Scrypted Dependencies via Command Line on Mac Source: https://github.com/koush/scrypted/wiki/Installation:-Mac This script downloads and installs all necessary dependencies for Scrypted, including Node.js and Python, and sets up Scrypted as a service. Ensure Homebrew is installed before running. ```shell mkdir -p ~/.scrypted curl -s https://raw.githubusercontent.com/koush/scrypted/main/install/local/install-scrypted-dependencies-mac.sh > ~/.scrypted/install-scrypted-dependencies-mac.sh bash ~/.scrypted/install-scrypted-dependencies-mac.sh ``` -------------------------------- ### Build and Deploy BTicino Plugin Source: https://github.com/koush/scrypted/blob/main/plugins/bticino/README.md Commands to navigate to the plugin directory, install dependencies, build the project, and deploy it to a Scrypted instance. ```bash cd plugins/sip npm ci cd plugins/bticino npm ci npm run build num run scrypted-deploy 127.0.0.1 ``` -------------------------------- ### Install Scrypted Dependencies and Service on Linux Source: https://github.com/koush/scrypted/wiki/Installation:-Linux This script downloads all necessary dependencies, including Node.js 16 and Python, and installs Scrypted as a service. It is executed using curl and piped to bash with sudo privileges. The SERVICE_USER environment variable can be set to specify the user under which the service will run. ```shell curl -s https://raw.githubusercontent.com/koush/scrypted/main/install/local/install-scrypted-dependencies-linux.sh | sudo SERVICE_USER=$USER bash ``` -------------------------------- ### Install Docker CE on Ubuntu (WSL2) Source: https://github.com/koush/scrypted/wiki/Installation:-WSL2-Windows Installs Docker CE, CLI, and containerd.io on Ubuntu within WSL2. This command should be run after configuring the repository. ```bash sudo apt install docker-ce docker-ce-cli containerd.io ``` -------------------------------- ### Clone Scrypted and Install Dependencies Source: https://github.com/koush/scrypted/blob/main/README.md Clone the Scrypted repository and install server and plugin dependencies. This is a prerequisite for debugging plugins or the server. ```sh # this is an example for homekit. # check out the code git clone https://github.com/koush/scrypted cd scrypted # get the dependencies for the server and various plugins ./npm-install.sh ``` ```sh # check out the code git clone https://github.com/koush/scrypted cd scrypted # get the dependencies for the server and various plugins ./npm-install.sh ``` -------------------------------- ### Automate Docker Service Start on Windows Startup Source: https://github.com/koush/scrypted/wiki/Installation:-WSL2-Windows Creates a batch file to automatically start the Docker service in WSL2 every time your Windows machine reboots. Place this file in your Windows startup folder. ```batch wsl.exe -u root -e bash -c "service docker start" ``` -------------------------------- ### Install Scrypted via PowerShell Script Source: https://github.com/koush/scrypted/wiki/Installation:-Windows Execute this command in an administrative PowerShell terminal to download and install Scrypted, including its dependencies, as a service. This script installs Scrypted and makes it accessible at https://localhost:10443/. ```powershell iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/koush/scrypted/main/install/local/install-scrypted-dependencies-win.ps1')) ``` -------------------------------- ### Install Watchtower Docker Container Source: https://github.com/koush/scrypted/wiki/Installation:-Docker-Linux Run this command to install Watchtower, which will automatically update Scrypted. Ensure your user is in the docker group. ```bash docker run -d \ --name watchtower \ --restart unless-stopped \ -v /var/run/docker.sock:/var/run/docker.sock \ containrrr/watchtower:latest \ --interval 3600 --cleanup ``` -------------------------------- ### Install Docker Compose on Ubuntu (WSL2) Source: https://github.com/koush/scrypted/wiki/Installation:-WSL2-Windows Optional step to install Docker Compose on Ubuntu within WSL2. This allows for easier management of multi-container Docker applications. ```bash sudo apt install docker-compose ``` -------------------------------- ### Get Amcrest Doorbell Configuration Source: https://github.com/koush/scrypted/wiki/Amcrest-Doorbell-Experience Access this URL in a web browser to view the current configuration of your Amcrest doorbell. Use the credentials set during initial setup. ```bash http://[IPADDRESS]/cgi-bin/configManager.cgi?action=getConfig&name=Encode ``` -------------------------------- ### Install Scrypted Docker Container Source: https://github.com/koush/scrypted/wiki/Installation:-Docker-Linux Execute this command to download and run the Scrypted Docker container. It maps the local .scrypted directory to the container's volume and uses the host network for access. ```bash docker run -d \ --name scrypted \ --network host \ --restart unless-stopped \ -v ~/.scrypted:/server/volume \ koush/scrypted:latest ``` -------------------------------- ### Access Scrypted UI Source: https://github.com/koush/scrypted/wiki/Local-Installation-(Advanced) After starting the server, access the Scrypted user interface by navigating to the specified URL in your web browser. ```shell # visit https://localhost:10443/ in a browser ``` -------------------------------- ### Configure Docker CE Repository on Ubuntu (WSL2) Source: https://github.com/koush/scrypted/wiki/Installation:-WSL2-Windows Configures the upstream Docker CE repository for installation on Ubuntu within WSL2. Ensure you are in your WSL2 distribution. ```bash source /etc/os-release curl -fsSL https://download.docker.com/linux/${ID}/gpg | sudo apt-key add - echo "deb [arch=amd64] https://download.docker.com/linux/${ID} ${VERSION_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/docker.list sudo apt update ``` -------------------------------- ### Configure Scrypted systemd service with custom ffmpeg Source: https://github.com/koush/scrypted/wiki/Live-Video-Editing-and-Markup Example of how to modify the Scrypted systemd service file to always use a custom ffmpeg path. Replace `` with your actual username. ```ini [Unit] Description=Scrypted service After=network.target [Service] User= Group= Type=simple Environment="SCRYPTED_FFMPEG_PATH=/home//Applications/ffmpeg-for-scrypted/bin/ffmpeg" ExecStart=/usr/bin/npx -y scrypted serve Restart=on-failure RestartSec=3 [Install] WantedBy=multi-user.target ``` -------------------------------- ### Verify Node Version Source: https://github.com/koush/scrypted/wiki/Local-Installation-(Advanced) Check if the installed Node.js version is compatible, ideally around v16.13.0. Other versions may cause issues. ```shell # Verify node version ~v16.13.0 node -v ``` -------------------------------- ### Configure MQTT Button Subscription Source: https://github.com/koush/scrypted/wiki/Do-It-Yourself-Doorbell-(Custom-Doorbell-Button) This code snippet configures the MQTT subscription for a button. Ensure your MQTT server details, topic, and expected payload ('DING' in this example) are correctly set. ```typescript mqtt.subscribe({ 'button': value => device.binaryState = value.text === "DING"; }) mqtt.handleTypes(ScryptedInterface.BinarySensor); ``` -------------------------------- ### Restart Docker Compose for EdgeTPU Drivers Source: https://github.com/koush/scrypted/blob/main/plugins/tensorflow-lite/README.md After installing EdgeTPU drivers on the Docker host, restart the Docker Compose services to apply the changes. ```bash cd ~/.scrypted docker compose down docker compose up -d ``` -------------------------------- ### Enable Podman Auto Update Timer Source: https://github.com/koush/scrypted/wiki/Installation:-Podman-Linux Enable and start the Podman auto-update timer for daily Scrypted container updates. This command ensures that the system will automatically check for and apply updates to the Scrypted container on a daily basis. ```bash sudo systemctl enable --now podman-auto-update.timer ``` -------------------------------- ### Manage Scrypted Systemd Service Source: https://github.com/koush/scrypted/wiki/Installation:-Podman-Linux Reload the systemd daemon to recognize the new service file and then start the Scrypted container. Ensure the systemd daemon is reloaded after making changes to service files. ```bash systemctl daemon-reload systemctl start scrypted ``` -------------------------------- ### Allow Unsigned Scripts in PowerShell Source: https://github.com/koush/scrypted/wiki/Installation:-Windows Use this command in an administrative PowerShell terminal to allow the execution of unsigned scripts, which is necessary for installing Scrypted via the command line. ```powershell Set-ExecutionPolicy Unrestricted ``` -------------------------------- ### Build and Deploy HomeKit Plugin Source: https://github.com/koush/scrypted/blob/main/README.md Build and deploy the HomeKit plugin directly from the command line. Ensure you are in the plugins/homekit directory. ```sh # currently in the plugins/homekit directory. npm run build && npm run scrypted-deploy 127.0.0.1 ``` -------------------------------- ### Configure Flexisip Transports (Specific IP) Source: https://github.com/koush/scrypted/blob/main/plugins/bticino/README.md Modify the flexisip startup script to bind to a specific IP address for SIP and SIPS transports. Ensure the IP address is correct for your network. ```bash case "$1" in start) start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_ARGS --transports "sips:$2:5061;maddr=$2;require-peer-certificate=1 sip:127.0.0.1;maddr=127.0.0.1 sip:192.168.0.XX;maddr=192.168.0.XX" ;; ``` -------------------------------- ### Configure Flexisip Global and Authentication Settings Source: https://github.com/koush/scrypted/blob/main/plugins/bticino/README.md Set logging levels to debug and configure trusted hosts in flexisip.conf. Adding your baresip server's IP to `trusted-hosts` allows registration without username/password authentication. ```ini [global] ... log-level=debug syslog-level=debug [module::Authentication] enabled=true auth-domains=c300x.bs.iotleg.com db-implementation=file datasource=/etc/flexisip/users/users.db.txt trusted-hosts=127.0.0.1 192.168.0.XX hashed-passwords=true reject-wrong-client-certificates=true ``` -------------------------------- ### Add ffmpeg lib directory to path Source: https://github.com/koush/scrypted/wiki/Live-Video-Editing-and-Markup Steps to update the dynamic linker configuration to include the newly built ffmpeg libraries. Replace `` with your actual username. ```bash sudo nano /etc/ld.so.conf /home//Applications/ffmpeg-for-scrypted/ffmpeg_build/lib sudo ldconfig ``` -------------------------------- ### Build ffmpeg for Scrypted Source: https://github.com/koush/scrypted/wiki/Live-Video-Editing-and-Markup Commands to build a custom ffmpeg version with necessary libraries for HomeKit compatibility. Ensure to replace placeholders with your actual paths. ```bash mkdir ~/Applications/ffmpeg-for-scrypted && cd ~/Applications/ffmpeg-for-scrypted sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libtheora-dev libtool libvorbis-dev pkg-config texinfo zlib1g-dev sudo apt-get install libfdk-aac-dev libmp3lame-dev yasm libx264-dev libx265-dev https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 tar xjvf ffmpeg-snapshot.tar.bz2 cd ffmpeg PATH="$HOME/Applications/ffmpeg-for-scrypted/bin:$PATH" PKG_CONFIG_PATH="$HOME/Applications/ffmpeg-for-scrypted/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/Applications/ffmpeg-for-scrypted/ffmpeg_build" --pkg-config-flags="--static" --extra-cflags="-I$HOME/Applications/ffmpeg-for-scrypted/ffmpeg_build/include" --extra-ldflags="-L$HOME/Applications/ffmpeg-for-scrypted/ffmpeg_build/lib" --bindir="$HOME/Applications/ffmpeg-for-scrypted/bin" --enable-shared --enable-libx264 --enable-libx265 --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-nonfree --enable-gpl PATH="$HOME/Applications/ffmpeg-for-scrypted/bin:$PATH" make make install make distclean hash -r ``` -------------------------------- ### Apply HomeKit H264 Encoder Arguments Source: https://github.com/koush/scrypted/wiki/Live-Video-Editing-and-Markup Arguments to configure HomeKit transcoding for Scrypted cameras, enabling live video markup with timestamps. Adjust font size and position as needed. ```bash -vf drawtext=fontfile=/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf:text='%{localtime}':fontsize=72:fontcolor=red@1.0:x=10:y=10 -vcodec libx264 -preset ultrafast -tune zerolatency -b:v 600k ``` -------------------------------- ### Add Scrypted User Agent to Flexisip Source: https://github.com/koush/scrypted/blob/main/plugins/bticino/README.md Define a new user agent for scrypted in the users.db.txt file. Use a placeholder MD5 hash for the password, as it's not strictly enforced when using trusted hosts. ```text c300x@1234567.bs.iotleg.com md5:ffffffffffffffffffffffffffffffff ; scrypted@1234567.bs.iotleg.com md5:ffffffffffffffffffffffffffffffff ; ``` -------------------------------- ### Amcrest AD110 Talk Action Invite Event Source: https://github.com/koush/scrypted/blob/main/plugins/amcrest/ad110.md This event signifies a 'Talk' action initiated by the doorbell, specifically an 'Invite' to start a call. It contains call-related identifiers. ```text event --myboundary Content-Type: text/plain Content-Length:148 Code=_DoTalkAction_;action=Pulse;index=0;data={ "Action" : "Invite", "CallID" : "20220406200813@670064@192.168.x.x”, "CallSrcMask" : 4 } ``` -------------------------------- ### Connect and Control Scrypted Device Source: https://github.com/koush/scrypted/blob/main/packages/client/README.md Connect to the Scrypted client and control a device. Ensure you have the necessary environment variables or default credentials set for username and password. ```javascript import { connectScryptedClient, OnOff } from '@scrypted/client'; async function example() { const sdk = await connectScryptedClient({ baseUrl: 'https://localhost:10443', pluginId: "@scrypted/core", username: process.env.SCRYPTED_USERNAME || 'admin', password: process.env.SCRYPTED_PASSWORD || 'swordfish', }); const dimmer = sdk.systemManager.getDeviceByName("Office Dimmer"); dimmer.turnOn(); await new Promise(resolve => setTimeout(resolve, 5000)); await dimmer.turnOff(); // allow node to exit sdk.disconnect(); } example(); ``` -------------------------------- ### Verify Flexisip Process Source: https://github.com/koush/scrypted/blob/main/plugins/bticino/README.md Check the running flexisip processes to confirm it is listening on the configured IP addresses and ports after reboot. This verifies the configuration changes. ```bash ~# ps aux|grep flexis bticino 741 0.0 0.3 9732 1988 ? SNs Oct28 0:00 /usr/bin/flexisip --daemon --syslog --pidfile /var/run/flexisip.pid --p12-passphrase-file /var/tmp/bt_answering_machine.fifo --transports sips:192.168.0.XX:5061;maddr=192.168.0.XX;require-peer-certificate=1 sip:127.0.0.1;maddr=127.0.0.1 sip:192.168.0.XX;maddr=192.168.0.XX bticino 742 0.1 1.6 45684 8408 ? SNl Oct28 1:44 /usr/bin/flexisip --daemon --syslog --pidfile /var/run/flexisip.pid --p12-passphrase-file /var/tmp/bt_answering_machine.fifo --transports sips:192.168.0.XX:5061;maddr=192.168.0.XX;require-peer-certificate=1 sip:127.0.0.1;maddr=127.0.0.1 sip:192.168.0.XX;maddr=192.168.0.XX ``` -------------------------------- ### Create Reset Login File Source: https://github.com/koush/scrypted/wiki/Lost-Password-and-User-Reset Create the `reset-login` file in the Scrypted volume directory to trigger a user reset. This action will prompt for a new admin account creation upon the next login page reload. ```bash touch ~/.scrypted/volume/reset-login ``` -------------------------------- ### Run Scrypted with custom ffmpeg (terminal) Source: https://github.com/koush/scrypted/wiki/Live-Video-Editing-and-Markup Command to run Scrypted with a specific ffmpeg path for testing purposes. Ensure Scrypted service is stopped first. Replace `` with your actual username. ```bash sudo systemctl stop scrypted.service SCRYPTED_FFMPEG_PATH=/home//Applications/ffmpeg-for-scrypted/bin/ffmpeg /usr/bin/npx -y scrypted serve ``` -------------------------------- ### Configure MQTT Motion Sensor in Scrypted Source: https://github.com/koush/scrypted/wiki/Wyze Use this code to create a motion sensor that triggers on 'ON' messages from an MQTT topic. Ensure the MQTT plugin is enabled and a custom handler is added. ```typescript createMotionSensor({ topic: 'motion', when: ({text}) => text === 'ON', delay: 10 }) ``` -------------------------------- ### Accept All Incoming Traffic Source: https://github.com/koush/scrypted/blob/main/plugins/bticino/README.md Temporarily disable the firewall by setting default policies to ACCEPT for all traffic. This is a quick way to test connectivity but should be done with caution. ```bash iptables -P INPUT ACCEPT iptables -P FORWARD ACCEPT iptables -P OUTPUT ACCEPT ``` -------------------------------- ### Configure Flexisip Transports (Dynamic IP) Source: https://github.com/koush/scrypted/blob/main/plugins/bticino/README.md Configure flexisip to use the device's current WiFi IP address for SIP and SIPS transports. This is useful for dynamic network environments. ```bash start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_ARGS --transports "sips:$2:5061;maddr=$2;require-peer-certificate=1 sip:127.0.0.1;maddr=127.0.0.1 sip:$2;maddr=$2" ``` -------------------------------- ### Open Scrypted Server Project in VS Code Source: https://github.com/koush/scrypted/blob/main/README.md Open the Scrypted server project in VS Code for debugging. This is generally not necessary as the server provides hosting and RPC mechanisms for plugins. ```sh # open server project in VS Code code server ``` -------------------------------- ### Enable verbose ffmpeg logging in Scrypted Source: https://github.com/koush/scrypted/wiki/Live-Video-Editing-and-Markup REPL commands to toggle verbose ffmpeg output in Scrypted for debugging. Use the first command to enable and the second to disable. ```javascript localStorage.setItem('SCRYPTED_FFMPEG_NOISY', 'true') ``` ```javascript localStorage.removeItem('SCRYPTED_FFMPEG_NOISY', 'true') ``` -------------------------------- ### Debug HomeKit Plugin in VS Code Source: https://github.com/koush/scrypted/blob/main/README.md Open the HomeKit plugin project in VS Code for debugging. Changes to the plugin can be deployed to a running server without restarting the server. ```sh # open the homekit project in VS Code code plugins/homekit ``` -------------------------------- ### Extract libatomic.so.1 from .deb package Source: https://github.com/koush/scrypted/blob/main/plugins/bticino/README.md Command to extract the libatomic.so.1 file from the downloaded .deb package, which is a required dependency for Node.js on the device. ```bash ar x libatomic1-armhf-cross_10.2.1-6cross1_all.deb ``` -------------------------------- ### Configure MQTT Handler for Shelly Button Source: https://github.com/koush/scrypted/wiki/Do-It-Yourself-Doorbell This code snippet is specific to Shelly devices. It subscribes to MQTT messages for the relay status and updates the binary sensor state accordingly. Adjust the topic and value check if using a different MQTT device. ```javascript mqtt.subscribe({ 'relay/0': value => device.binaryState = value.text === 'on', }); mqtt.handleTypes(ScryptedInterface.BinarySensor); ``` -------------------------------- ### Remount Root Filesystem Source: https://github.com/koush/scrypted/blob/main/plugins/bticino/README.md Remount the root filesystem in read-write mode to allow modifications. ```bash $ mount -oremount,rw / ```