Jump to content

SENSBLUE ATLAS/Home Assistant: Difference between revisions

No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 7: Line 7:
         <span class="atlas-btn">[[Media:Atlas-ha-install-v1.zip|Download Script]]</span>
         <span class="atlas-btn">[[Media:Atlas-ha-install-v1.zip|Download Script]]</span>
     </td>
     </td>
</table>This script takes a backup file as an argument and contains: <code>.tar.gz</code> <syntaxhighlight lang="bash">
</table>The package is a copy of the reference installation. It includes the same version of Home Assistant (2026.8.0), the YAML files, HACS, themes, images, dashboards, and helpers.
 
Package structure: <syntaxhighlight lang="bash">
atlas-ha-installer/
atlas-ha-installer/
├── docker-compose.yml
├── docker-compose.yml        # imagem fixa: home-assistant:2026.8.0
├── install.sh
├── install.sh
├── README.md
├── README.md
├── provision_areas.py
├── provision_areas.py
└── ha-config/
└── ha-config/
    ├── configuration.yaml
    ├── configuration.yaml
    ├── mqtt.yaml
    ├── mqtt.yaml
    ├── automations.yaml
    ├── automations.yaml
    ├── scripts.yaml
    ├── scripts.yaml
    └── scenes.yaml
    ├── scenes.yaml
    ├── secrets.yaml          # vazio
    ├── custom_components/    # inclui HACS
    ├── www/
    ├── themes/
    ├── image/
    ├── blueprints/           # se existir
    └── .storage/             # apenas lovelace* (dashboards) e input_* (helpers)
 
</syntaxhighlight>
</syntaxhighlight>


=== 1. What the script does ===
=== 1. What the script does ===
The <code>install.sh</code> doesn't need any arguments.
{| class="wikitable mix-table"
{| class="wikitable mix-table"
!Stage
!Stage
!Action
!Action
|-
|-
|Validates argument
|1–3. Docker
|Confirms that a backup file was specified
|Installs Docker Engine and the Docker Compose plugin from the official Docker repository. If Docker already exists, skips this step.
|-
|-
|Installs dependencies
|4. Create folders
|Run <code>apt update</code> and install <code>docker.io</code> and <code>docker-compose-plugin</code>
|Creates <code>/opt/atlas-ha</code> and <code>/opt/atlas-ha/ha-config</code>.
|-
|-
|Enables Docker
|5. Copy compose
|Executes <code>systemctl enable docker</code> and <code>systemctl start docker</code>
|Copies the <code>docker-compose.yml</code>, with the fixed HA version.
|-
|-
|Breed pasta
|6. Copy configuration
|Ensure <code>/opt/atlas-ha</code> exists
|Copies the entire <code>ha-config</code> folder (<code>cp -a</code>) and creates empty <code>automations.yaml</code>, <code>scripts.yaml</code>, and <code>scenes.yaml</code> if they do not exist.
|-
|-
|Extract backup
|7. Permissions
|Extract the <code>.tar.gz</code> file to <code>/opt/atlas-ha</code>
|Runs <code>chown -R root:root /opt/atlas-ha</code>.
|-
|-
|HA starts up
|8. Start HA
|Navigates to <code>/opt/atlas-ha</code> and runs <code>sudo docker compose up -d</code>
|Runs <code>docker compose up -d</code>.
|-
|-
|Show URL
|9. Validate
|Indicate access via <code><nowiki>http://DEVICE_IP:8123</nowiki></code>
|Runs <code>check_config</code> inside the container and restarts HA.
|}
|}


=== 2. Prepare Device ===
=== 2. What is not included in the package: ===
Transfer the package to ATLAS, for example using WinSCP:
The following data remains in <code>.storage</code> and is '''not''' copied, for security reasons and because they are different on each unit:
 
* users and tokens;
* database and history;
* device and entity registry;
* MQTT broker connection (integration);
* HACS authentication (GitHub).
 
Therefore, on each new unit, it is necessary to configure the MQTT integration and HACS (see 16.6).
 
If you rename entities through the HA interface, those changes are not carried over to the package. Names must be defined in <code>mqtt.yaml</code>.
 
=== 3. Prepare Device ===
Transfer the package to ATLAS, for example using [https://winscp.net/eng/index.php <u>WinSCP</u>]:


# Open the connection to ATLAS using WinSCP.
# Open the connection to ATLAS using WinSCP.
# Copy <code>atlas-ha-installer.zip</code> or <code>atlas-ha-installer.tar.gz</code> to <code>/home/pi</code>.
# Copy <code>atlas-ha-installer.zip</code> to <code>/home/pi</code>.
# Drag the folder extracted from the .zip file to the /home/pi directory on ATLAS.
# Establish an SSH connection to ATLAS.


'''Note:''' If you need help installing WinSCP, '''''<u>[[SENSBLUE ATLAS/Putty & WinSCP#Install WinSCP|click here]]</u>'''''.
'''Note:''' If you need help installing WinSCP, '''''<u>[[SENSBLUE ATLAS/Putty & WinSCP#Install WinSCP|click here]]</u>'''''.


On ATLAS, after transferring the necessary files, establish an SSH connection
Alternatively, from another ATLAS:<syntaxhighlight lang="bash">
 
scp ~/atlas-ha-installer.zip pi@<ip-do-atlas>:~
If the package is <code>.zip</code>:<syntaxhighlight lang="bash">
</syntaxhighlight>On ATLAS, extract the package:<syntaxhighlight lang="bash">
sudo apt-get update
sudo apt-get install -y unzip
cd /home/pi
cd /home/pi
rm -rf atlas-ha-installer
unzip atlas-ha-installer.zip
unzip atlas-ha-installer.zip
cd atlas-ha-installer
cd atlas-ha-installer
</syntaxhighlight>Se o pacote for :<code>.tar.gz</code><syntaxhighlight lang="bash">
cd /home/pi tar -xzf atlas-ha-installer.tar.gz cd atlas-ha-installer
</syntaxhighlight>Grant execution permission<syntaxhighlight lang="bash">
chmod +x install.sh
chmod +x install.sh
</syntaxhighlight>
</syntaxhighlight>


=== 3. Execute installation ===
=== 4. Run the installation: ===
The script will install the required dependencies, install/configure Docker, copy the files to <code>/opt/atlas-ha</code>, and start Home Assistant.<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">sudo ./install.sh</syntaxhighlight>Na primeira execução, o script demora alguns minutos por causa do download da imagem do Home Assistant.
sudo ./install.sh
 
</syntaxhighlight>After installation, the following should exist:<syntaxhighlight>
Depois da instalação, deve existir:<syntaxhighlight lang="bash">
/opt/atlas-ha/
/opt/atlas-ha/
├── docker-compose.yml
├── docker-compose.yml
└── ha-config/
└── ha-config/
    ├── configuration.yaml
    ├── configuration.yaml
    ├── mqtt.yaml
    ├── mqtt.yaml
    ├── automations.yaml
    ├── automations.yaml
    ├── scripts.yaml
    ├── scripts.yaml
    └── scenes.yaml
    ├── scenes.yaml
    ├── custom_components/
    ├── www/
    ├── themes/
    ├── image/
    └── .storage/
</syntaxhighlight>
</syntaxhighlight>


=== 4. Post-script validation ===
=== 5. Post-script validation ===
Verify that the container is active:<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo docker ps
sudo docker ps
</syntaxhighlight>Check logs:<syntaxhighlight lang="bash">
sudo docker logs -f homeassistant
</syntaxhighlight>Verify HTTP response:<syntaxhighlight lang="bash">
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8123
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8123
</syntaxhighlight>Expected result:
</syntaxhighlight>
{| class="wikitable mix-table"
{| class="wikitable mix-table"
!Code
!Code
Line 96: Line 122:
|-
|-
|200
|200
|Home Assistant access
|Home Assistant accessible
|-
|-
|302
|302
Line 102: Line 128:
|-
|-
|000 or connection refused  
|000 or connection refused  
|It can be normal for the first 1–2 minutes; wait and repeat.
|May be normal in the first 1–2 minutes; wait and try again
|}Access in browser<syntaxhighlight>
|}
http://<ip-do-atlas>:8123
To view the logs:<syntaxhighlight>
sudo docker logs -f homeassistant
</syntaxhighlight>
</syntaxhighlight>
=== 6.  Initial configuration in the browser ===
Open <code>http://<ip-of-atlas>:8123</code>:
# '''Create the administrator account.''' It should not be the same across all units (see section 15).
# '''Configure the location, time zone, and units.'''
# '''Add the MQTT integration:''' <code>Settings → Devices & services → Add integration → MQTT</code>  - Broker: 127.0.0.1  - Port: 1883  - Username/password: according to the Mosquitto configuration
# '''Add the HACS integration:''' <code>Settings → Devices & services → Add integration → HACS</code> and authorize with GitHub.
# '''Restart Home Assistant:''' <code>Settings → System → Restart.</code>
=== 7. Validate the installation ===
{| class="wikitable mix-table"
!Verification
!Where
!Expected result
|-
|Version
|<code>Settings → About</code>
|<code>2026.8.0</code>
|-
|ATLAS Device
|<code>Settings → Devices & services → MQTT</code>
|Device with entities
|-
|Analog Inputs (AI1..AI4)
|'''Analog''' Dashboard
|Values updating
|-
|Analog Outputs (AO1..AO2)
|'''Analog''' Dashboard
|Correct values and control working
|-
|Digital Inputs (DI1..DI4)
|'''Digital''' Dashboard
|States updating
|-
|Digital Outputs (DO1..DO8)
|'''Digital''' Dashboard
|Correct state and control working
|-
|System Health
|'''System''' Dashboard
|CPU, RAM, disk, and eMMC with values
|-
|Automations
|<code>Settings → Automations</code>
|"ATLAS Read …" automations active
|-
|Themes and images
|Profile / dashboards
|Identical to the reference unit
|}
=== 8. Troubleshooting ===
{| class="wikitable mix-table"
!Problem
!Probable cause / solution
|-
|<code>curl</code> devolve <code>000</code>
|O HA ainda está a arrancar. Ver <code>sudo docker logs -f homeassistant</code>.
|-
|<code>check_config</code> error
|YAML error; the log indicates the file and line. Fix in <code>/opt/atlas-ha/ha-config/</code> and run <code>sudo docker compose restart</code>.
|-
|Entities without data
|The MQTT integration is not configured (16.6) or Mosquitto is not responding on port <code>1883</code>.
|-
|Missing dashboards
|Confirm that <code>/opt/atlas-ha/ha-config/.storage/lovelace*</code> exists.
|-
|Missing themes or cards
|Confirm the <code>themes</code> and <code>www</code> folders exist; clear your browser cache.
|-
|<code>apt-get update</code> gives a <code>404</code> error on the Docker repository
|See the note about Debian 13 <code>Trixie</code> in section 3.
|}
=== 9. Updating the installer package (maintenance) ===
Use this procedure when changes are made to the reference unit's Home Assistant and the package needs to reflect them. Run on the '''reference unit:'''
'''1. Make a backup of the current installer:'''<syntaxhighlight lang="bash">cd ~
   cp -r atlas-ha-installer atlas-ha-installer.bak-$(date +%F)</syntaxhighlight>'''2. Synchronize the running configuration, excluding sensitive data:'''<syntaxhighlight lang="bash">
sudo rsync -av --delete \
  --exclude '.storage' --exclude '*.db*' --exclude '*.log*' \
  --exclude 'secrets.yaml' --exclude '.HA_VERSION' --exclude '.cloud' \
  --exclude 'deps' --exclude 'tts' --exclude 'backups' --exclude '__pycache__' \
  /opt/atlas-ha/ha-config/ ~/atlas-ha-installer/ha-config/
</syntaxhighlight>'''3. Copy dashboards and helpers:'''<syntaxhighlight lang="bash">
mkdir -p ~/atlas-ha-installer/ha-config/.storage
sudo bash -c 'cp /opt/atlas-ha/ha-config/.storage/lovelace* /home/pi/atlas-ha-installer/ha-config/.storage/ 2>/dev/null'
sudo bash -c 'cp /opt/atlas-ha/ha-config/.storage/input_* /home/pi/atlas-ha-installer/ha-config/.storage/ 2>/dev/null'
sudo chown -R pi:pi ~/atlas-ha-installer
</syntaxhighlight>'''4. Pin the running HA version:'''<syntaxhighlight lang="bash">
cp /opt/atlas-ha/docker-compose.yml ~/atlas-ha-installer/docker-compose.yml
sed -i "s|home-assistant:stable|home-assistant:$(cat /opt/atlas-ha/ha-config/.HA_VERSION)|" ~/atlas-ha-installer/docker-compose.yml
grep image ~/atlas-ha-installer/docker-compose.yml
</syntaxhighlight>If <code>docker-compose.yml</code> already has a fixed version instead of <code>stable</code>, manually edit the <code>image:</code> line to the current version.
'''5. Confirm that no sensitive data is included. The command should return nothing:'''<syntaxhighlight lang="bash">
find ~/atlas-ha-installer -type f | grep -E 'auth|token|onboarding|core\.|\.db|\.log|cloud'
</syntaxhighlight>'''6. Generate the package:'''<syntaxhighlight lang="bash">
cd ~
rm -f atlas-ha-installer.zip
zip -r atlas-ha-installer.zip atlas-ha-installer
unzip -l atlas-ha-installer.zip | grep -E "install.sh|docker-compose|storage|configuration.yaml"
</syntaxhighlight>'''7. Test the package''' on a clean unit (16.3 to 16.7) and only then replace the <code>atlas-ha-installer.zip</code> attachment on this page.
=== 10. Uninstall / Revert ===
Run on the unit to be cleaned. Confirm beforehand with <code>hostname</code>. The <code>rm -rf</code> steps cannot be undone.
Before removing:<syntaxhighlight lang="bash">
hostname
sudo docker ps -a
</syntaxhighlight>'''1. Remove only Home Assistant (keeps Docker)'''
Optionally, make a backup first:<syntaxhighlight lang="bash">
sudo tar -czf ~/atlas-ha-backup-$(date +%F).tar.gz -C /opt/atlas-ha .
</syntaxhighlight>Stop and remove the container, image, and configuration:<syntaxhighlight lang="bash">
cd /opt/atlas-ha
sudo docker compose down
sudo docker image rm ghcr.io/home-assistant/home-assistant:2026.8.0
cd ~
sudo rm -rf /opt/atlas-ha
rm -rf ~/atlas-ha-installer ~/atlas-ha-installer.zip
</syntaxhighlight>'''2. Also remove Docker (optional)'''
Only remove Docker if <code>docker ps -a</code> does not show other necessary containers.<syntaxhighlight lang="bash">
sudo apt purge -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
sudo apt autoremove -y
sudo rm -rf /var/lib/docker /var/lib/containerd
sudo rm -f /etc/apt/sources.list.d/docker.list /etc/apt/keyrings/docker.asc /etc/apt/keyrings/docker.gpg
sudo apt update
</syntaxhighlight>'''3. Confirm'''<syntaxhighlight lang="bash">ls /opt/atlas-ha 2>/dev/null || echo "Home Assistant removed"
command -v docker || echo "Docker removed"</syntaxhighlight>The native ATLAS stack (Node-RED, Grafana, InfluxDB, and Mosquitto) is not removed by these steps.


= Home Assistant integration =
= Home Assistant integration =
Line 136: Line 297:
|System
|System
|Debian GNU/Linux 13 trixie
|Debian GNU/Linux 13 trixie
|-
|Terminal emulator
|i.e. PuTTY - '''<u>https://putty.org/index.html</u>'''
|-
|-
|Access
|Access
Line 245: Line 409:
==== 3.4 Add Docker repository ====
==== 3.4 Add Docker repository ====
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \ https://download.docker.com/linux/debian \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \ https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
</syntaxhighlight>
</syntaxhighlight>