Skip to content

Commit ed5e569

Browse files
committed
Add HA addon
1 parent fbe3b9a commit ed5e569

File tree

4 files changed

+129
-0
lines changed

4 files changed

+129
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ARG SERVER_IMAGE=docker.io/strangev/remote-webview-server:latest
2+
FROM ${SERVER_IMAGE}
3+
4+
USER root
5+
RUN apt-get update \
6+
&& apt-get install -y --no-install-recommends jq socat ca-certificates curl \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
WORKDIR /app
10+
COPY run.sh /run.sh
11+
RUN chmod +x /run.sh
12+
13+
EXPOSE 8081 18080 9221
14+
15+
CMD ["/run.sh"]
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: "Remote WebView Server"
2+
version: "1.0.0"
3+
slug: "remote_webview_server"
4+
description: "Streams your HA dashboard or any website to ESP32-based displays as tiles via WebSocket."
5+
url: "https://github.com/strange-v/RemoteWebViewServer/tree/main/hassio/remote_webview_server"
6+
arch:
7+
- amd64
8+
- aarch64
9+
startup: application
10+
boot: auto
11+
12+
host_network: true
13+
14+
video: true
15+
udev: true
16+
init: false
17+
18+
watchdog: "http://[HOST]:[PORT:18080]/"
19+
20+
map:
21+
- type: addon_config
22+
read_only: false
23+
24+
options:
25+
screen_w: 480
26+
screen_h: 480
27+
tile_size: 32
28+
full_frame_tile_count: 4
29+
full_frame_area_threshold: 0.5
30+
full_frame_every: 50
31+
every_nth_frame: 1
32+
min_frame_interval_ms: 80
33+
jpeg_quality: 85
34+
max_bytes_per_message: 61440
35+
ws_port: 8081
36+
debug_port: 9221
37+
expose_debug_proxy: false
38+
debug_proxy_port: 9222
39+
health_port: 18080
40+
user_data_dir: "/pw-data"
41+
42+
schema:
43+
screen_w: int
44+
screen_h: int
45+
tile_size: int
46+
full_frame_tile_count: int
47+
full_frame_area_threshold: float
48+
full_frame_every: int
49+
every_nth_frame: int
50+
min_frame_interval_ms: int
51+
jpeg_quality: int
52+
max_bytes_per_message: int
53+
ws_port: int
54+
debug_port: int
55+
expose_debug_proxy: bool
56+
debug_proxy_port: int
57+
health_port: int
58+
user_data_dir: str
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
OPTIONS_FILE="/data/options.json"
5+
6+
get_opt() {
7+
local key="$1" default="$2"
8+
if [ -f "$OPTIONS_FILE" ]; then
9+
jq -r --arg k "$key" --arg d "$default" '.[$k] // $d' "$OPTIONS_FILE"
10+
else
11+
echo "$default"
12+
fi
13+
}
14+
15+
export SCREEN_W="$(get_opt screen_w 480)"
16+
export SCREEN_H="$(get_opt screen_h 480)"
17+
export TILE_SIZE="$(get_opt tile_size 32)"
18+
export FULL_FRAME_TILE_COUNT="$(get_opt full_frame_tile_count 4)"
19+
export FULL_FRAME_AREA_THRESHOLD="$(get_opt full_frame_area_threshold 0.5)"
20+
export FULL_FRAME_EVERY="$(get_opt full_frame_every 50)"
21+
export EVERY_NTH_FRAME="$(get_opt every_nth_frame 1)"
22+
export MIN_FRAME_INTERVAL_MS="$(get_opt min_frame_interval_ms 80)"
23+
export JPEG_QUALITY="$(get_opt jpeg_quality 85)"
24+
export MAX_BYTES_PER_MESSAGE="$(get_opt max_bytes_per_message 14336)"
25+
export WS_PORT="$(get_opt ws_port 8081)"
26+
export DEBUG_PORT="$(get_opt debug_port 9221)"
27+
export HEALTH_PORT="$(get_opt health_port 18080)"
28+
29+
USER_DATA_DIR_OPT="$(get_opt user_data_dir "/pw-data")"
30+
if [ "$USER_DATA_DIR_OPT" = "/pw-data" ]; then
31+
mkdir -p /data/pw-data
32+
# if not already a symlink, make /pw-data -> /data/pw-data
33+
if [ ! -L /pw-data ]; then
34+
rm -rf /pw-data 2>/dev/null || true
35+
ln -s /data/pw-data /pw-data
36+
fi
37+
export USER_DATA_DIR="/pw-data"
38+
else
39+
mkdir -p "$USER_DATA_DIR_OPT"
40+
export USER_DATA_DIR="$USER_DATA_DIR_OPT"
41+
fi
42+
43+
EXPOSE_DEBUG_PROXY="$(get_opt expose_debug_proxy false)"
44+
if [ "$EXPOSE_DEBUG_PROXY" = "true" ]; then
45+
DEBUG_PROXY_PORT="$(get_opt debug_proxy_port 9222)"
46+
echo "[remote-webview] Starting debug proxy on :${DEBUG_PROXY_PORT} -> 127.0.0.1:${DEBUG_PORT}"
47+
socat -d -d "TCP-LISTEN:${DEBUG_PROXY_PORT},fork,reuseaddr,keepalive" "TCP:127.0.0.1:${DEBUG_PORT}" &
48+
fi
49+
50+
command -v node >/dev/null
51+
test -f dist/index.js
52+
53+
exec node dist/index.js

repository.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: Remote WebView Add-ons
2+
url: https://github.com/strange-v/RemoteWebViewServer
3+
maintainer: strange_v

0 commit comments

Comments
 (0)