mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-18 04:49:13 +00:00
PR #544's change, ported onto the api_v3 package split (#553). Identical behaviour; only the placement of the new code differs. The original added 508 lines to web_interface/blueprints/api_v3.py, which #553 deletes, so every hunk of it would conflict irreconcilably. Ported by AST: 26 new top-level items sorted to where the split puts each kind -- __init__.py 2 imports, 11 constants, 7 helpers starlark.py 4 routes (/starlark/editor/{apps,status,start,stop}) misc.py 2 routes (/integrations/mqtt-bridge{,/config}) Everything outside api_v3.py -- the Tools partial, the installer scripts, the JS tests -- applied unchanged. Routes: 111 from the split plus these 6 = 117, and the url-map snapshot is regenerated to match, which is exactly what test_api_v3_url_map.py is designed to make you do when routes are added. Full Python suite: 4,278 passed, 68 skipped, 0 failed. The JS tests this PR ships could not be run here -- node is not installed on this machine -- so test/js/dom/test_tools_sections.js is unverified. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014RRtqXDCnvnY6EQwhT5CV9
65 lines
2.1 KiB
Bash
Executable File
65 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Home Assistant MQTT bridge installation script.
|
|
#
|
|
# Optional. Installs integrations/mqtt_bridge as a service so Home Assistant
|
|
# can force display modes, toggle power and set brightness over MQTT.
|
|
# See integrations/mqtt_bridge/README.md.
|
|
|
|
set -e
|
|
|
|
PROJECT_ROOT_DIR=$(cd "$(dirname "$0")/../.." && pwd)
|
|
BRIDGE_DIR="$PROJECT_ROOT_DIR/integrations/mqtt_bridge"
|
|
SERVICE_NAME="ledmatrix-mqtt-bridge"
|
|
UNIT_SRC="$PROJECT_ROOT_DIR/systemd/$SERVICE_NAME.service"
|
|
UNIT_DEST="/etc/systemd/system/$SERVICE_NAME.service"
|
|
|
|
if [ "$EUID" -eq 0 ]; then
|
|
SYSTEMCTL_CMD="systemctl"
|
|
SUDO=""
|
|
else
|
|
SYSTEMCTL_CMD="sudo systemctl"
|
|
SUDO="sudo"
|
|
fi
|
|
|
|
echo "Installing LED Matrix MQTT bridge"
|
|
echo "Project root directory: $PROJECT_ROOT_DIR"
|
|
|
|
if [ ! -f "$BRIDGE_DIR/bridge_config.json" ]; then
|
|
cp "$BRIDGE_DIR/bridge_config.example.json" "$BRIDGE_DIR/bridge_config.json"
|
|
chmod 600 "$BRIDGE_DIR/bridge_config.json"
|
|
echo ""
|
|
echo "⚠ Created $BRIDGE_DIR/bridge_config.json from the example."
|
|
echo " Edit it with your broker details, then re-run this script."
|
|
echo " The service will refuse to start until the placeholder password is replaced."
|
|
echo ""
|
|
fi
|
|
|
|
echo "Installing Python dependencies..."
|
|
python3 -m pip install -r "$BRIDGE_DIR/requirements.txt" 2>/dev/null \
|
|
|| python3 -m pip install --break-system-packages -r "$BRIDGE_DIR/requirements.txt"
|
|
|
|
echo "Installing $UNIT_DEST..."
|
|
sed "s|__PROJECT_ROOT_DIR__|$PROJECT_ROOT_DIR|g" "$UNIT_SRC" \
|
|
| $SUDO tee "$UNIT_DEST" > /dev/null
|
|
|
|
$SYSTEMCTL_CMD daemon-reload
|
|
$SYSTEMCTL_CMD enable "$SERVICE_NAME.service"
|
|
$SYSTEMCTL_CMD restart "$SERVICE_NAME.service" || true
|
|
|
|
echo ""
|
|
if $SYSTEMCTL_CMD is-active --quiet "$SERVICE_NAME.service" 2>/dev/null; then
|
|
echo "✓ MQTT bridge is running"
|
|
echo " The matrix should appear in Home Assistant under Settings > Devices > MQTT."
|
|
else
|
|
echo "⚠ MQTT bridge is not running. Check the logs:"
|
|
echo " sudo journalctl -u $SERVICE_NAME -n 50"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Useful commands:"
|
|
echo " sudo systemctl status $SERVICE_NAME"
|
|
echo " sudo journalctl -u $SERVICE_NAME -f"
|
|
echo " sudo systemctl disable --now $SERVICE_NAME # Undo"
|
|
echo ""
|