Jump to content

SENSBLUE ATLAS/Home Assistant: Difference between revisions

No edit summary
No edit summary
Line 454: Line 454:
[[File:Home Assistant img 1.png|center|frameless|1037x1037px]]
[[File:Home Assistant img 1.png|center|frameless|1037x1037px]]
[[File:Home Assistant img 2.png|center|frameless|1037x1037px]]
[[File:Home Assistant img 2.png|center|frameless|1037x1037px]]
=== 12. Test MQTT communication ===
Install MQTT client if necessary:<syntaxhighlight lang="bash">
sudo apt-get install -y mosquitto-clients
</syntaxhighlight>View MQTT messages received by Home Assistant:<syntaxhighlight lang="bash">
mosquitto_sub -h 127.0.0.1 -t 'analogInputs/runtime/out' -v
mosquitto_sub -h 127.0.0.1 -t 'digitalInputs/runtime/out' -v
mosquitto_sub -h 127.0.0.1 -t 'digitalOutputs/runtime/out' -v
</syntaxhighlight>Send a test to a digital output:
<nowiki>**</nowiki>missing code
=== 13. Daily operation ===
Run these commands inside the folder:<syntaxhighlight lang="bash">
cd /opt/atlas-ha
</syntaxhighlight>
{| class="wikitable"
!Action
!Command
|-
|View logs
|sudo docker logs -f homeassistant
|-
|View status
|sudo docker ps
|-
|Restart
|sudo docker compose restart
|-
|Stop
|sudo docker compose stop
|-
|Start
|sudo docker compose start
|-
|Update
|sudo docker compose pull && sudo docker compose up -d
|}
=== 14. Configuration backup ===
The <code>ha-config</code> folder contains the Home Assistant state/configuration. Create a backup:<syntaxhighlight lang="bash">
sudo tar czf ~/atlas-ha-backup.tar.gz -C /opt/atlas-ha docker-compose.yml ha-config
</syntaxhighlight>
=== 15. Production notes ===
Before sending a unit to a client, review the following points:
{| class="wikitable"
!Point
!Note
|-
|MQTT Broker
|Mosquitto may be unauthenticated and listening on 0.0.0.0; secure before exposing the unit
|-
|Grafana
|Change default credentials, e.g., admin/admin
|-
|Access Point
|If ATLAS routes traffic via wlan0, validate FORWARD, DOCKER-USER, nftables rules and persistence
|-
|Initial HA account
|The admin account should not be the same on all units
|-
|Network
|Validate port exposure when the unit has a routable IP via Ethernet/LTE
|}
=== 16. Automatic installation with script ===
The current installation can be performed using the script:<syntaxhighlight lang="bash">
install-atlas-ha.sh
</syntaxhighlight>This script takes a backup <code>.tar.gz</code> file as an argument and installs/restores Home Assistant in:<syntaxhighlight lang="bash">
/opt/atlas-ha
</syntaxhighlight>
==== 16.1 Script used ====
<syntaxhighlight lang="bash">
#!/bin/bash
set -e
BACKUP_FILE="$1"
INSTALL_DIR="/opt/atlas-ha"
if [ -z "$BACKUP_FILE" ]; then
  echo "Usage:"
  echo "sudo ./install-atlas-ha.sh atlas-ha-backup.tar.gz"
  exit 1
fi
echo "Installing dependencies..."
sudo apt update
sudo apt install -y docker.io docker-compose-plugin
echo "Enabling Docker..."
sudo systemctl enable docker
sudo systemctl start docker
echo "Creating installation folder..."
sudo mkdir -p "$INSTALL_DIR"
echo "Extracting backup..."
sudo tar -xzvf "$BACKUP_FILE" -C "$INSTALL_DIR"
echo "Starting Home Assistant..."
cd "$INSTALL_DIR"
sudo docker compose up -d
echo "Installation complete."
echo "Access at: http://DEVICE_IP:8123"
</syntaxhighlight>
==== 16.2 What the script does ====
{| class="wikitable"
!Step
!Action
|-
|Validate argument
|Confirms a backup file was specified
|-
|Install dependencies
|Runs apt update and installs docker.io + docker-compose-plugin
|-
|Enable Docker
|Runs systemctl enable docker and systemctl start docker
|-
|Create folder
|Ensures /opt/atlas-ha exists
|-
|Extract backup
|Extracts the .tar.gz to /opt/atlas-ha
|-
|Start HA
|Enters /opt/atlas-ha and runs sudo docker compose up -d
|-
|Show URL
|Indicates access via <nowiki>http://DEVICE_IP:8123</nowiki>
|}
==== 16.3 Prepare files ====
Copy to ATLAS:<syntaxhighlight lang="bash">
install-atlas-ha.sh
atlas-ha-backup.tar.gz
</syntaxhighlight>Example with '''scp''' from PC: