Skip to content

Instantly share code, notes, and snippets.

@BillyNate
Last active November 30, 2025 12:39
Show Gist options
  • Select an option

  • Save BillyNate/856f62dfc480506e0116220bf24b01b4 to your computer and use it in GitHub Desktop.

Select an option

Save BillyNate/856f62dfc480506e0116220bf24b01b4 to your computer and use it in GitHub Desktop.
Home Assistant setup on Raspberry Pi with TinyCore Linux (RAM only OS)

Home Assistant setup on Raspberry Pi with TinyCore Linux (RAM only OS)

This is a revisit of https://gist.github.com/BillyNate/d3124edfa903f288bfc8b7f37a155971, but using some different methods.
These are the steps taken to have Home Assistant 2025.7.1 with Python 3.13 on piCore 16
Newer version might work as well (or maybe even better), but have not been tested.

Setup

Follow steps of Basic setup of TinyCore/PiCore on a Raspberry Pi

Install UV

  1. Install dependencies: tce-load -wi squashfs-tools
  2. Download, untar, pack, install & cleanup:
    mkdir -p ./tmp/usr/local/bin && \
    wget https://github.com/astral-sh/uv/releases/latest/download/uv-aarch64-unknown-linux-musl.tar.gz && \
    tar xvf uv-aarch64-unknown-linux-musl.tar.gz -C ./tmp/usr/local/bin --strip-components=1 && \
    mksquashfs ./tmp /etc/sysconfig/tcedir/optional/uv.tcz && \
    echo "uv.tcz" >> /etc/sysconfig/tcedir/onboot.lst && \
    tce-load -i uv && \
    rm -rf ./tmp uv-aarch64-unknown-linux-musl.tar.gz
    
  3. UV should now be available: uv --version
  4. Create persistent UV directory (this goes against the "RAM only", but is our best option):
    mkdir -p /etc/sysconfig/tcedir/persistent/uv && \
    mkdir ~/.local/share && \
    ln -s /etc/sysconfig/tcedir/persistent/uv ~/.local/share/uv
    
  5. Make sure UV's cache is also in the persistent directory:
    1. Create /etc/profile.d/uv.sh and add export UV_CACHE_DIR="$HOME/.local/share/uv/cache"
    2. Add /etc/profile.d/uv.sh to /opt/.filetool.lst
    3. Run source /etc/profile.d/uv.sh
  6. Save: backup

Install managed Python

  1. Install Python 3.13 through UV: uv python install 3.13
  2. Test: uv run python --version

Install Home Assistant

  1. Install dependencies: tce-load -wi compiletc rust bluez openssl-dev openjpeg-dev autoconf ffmpeg libjpeg-turbo-dev
  2. Install Home Assistant: uv tool install homeassistant (or use homeassistant==2025.7.1 for a specific version)
  3. Save: backup (only because ~/.local/bin/hass is created)
  4. Run Home Assistant once: uv tool run --from homeassistant hass -v --skip-pip, this generates the needed configuration
  5. Create persistent custom components directory:
    mkdir -p /etc/sysconfig/tcedir/persistent/custom_components && \
    ln -s /etc/sysconfig/tcedir/persistent/custom_components ~/.homeassistant/custom_components
    
  6. Optionally: Disable Cloud (Nabu Casa):
    1. Remove default_config from ~/.homeassistant/configuration.yaml
    2. Install Mostly Default Config as custom_component (see Install HACS on how to install a custom component)
    3. Update configuration.yaml:
      mostly_default_config:
      exclude:
        - cloud
        - ...
      
  7. Run Home Assistant again: uv tool run --from homeassistant hass -v and let it install the needed integrations. Once it says "Starting Home Assistant" it's finished!
  8. Open the web interface and create your basic config. Once done exit through Developer tools -> Services -> Home Assistant Core Integration: Stop
  9. Clean up the home directory as much as possible
  10. Add .homeassistant/home-assistant.log*, .homeassistant/tts, .homeassistant/deps, .homeassistant/*.db-wal & .homeassistant/*.db-shm to /opt/.xfiletool.lst
  11. Have Home Assistant start on boot:
    1. Create startup script /opt/hassboot.sh containing su - tc -c "uv tool run --from homeassistant hass -c /home/tc/.homeassistant"
    2. Turn startup script into executable: sudo chmod +x /opt/hassboot.sh
    3. Add /opt/hassboot.sh & to /opt/bootlocal.sh in order to have Home Assistant auto start at boot
  12. Save: backup

Use port 80

  1. Install iptables: tce-load -wi iptables
  2. Prepend iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8123 to /opt/hassboot.sh
  3. Save: backup

Seperate history data

Home Assistant records data and keeps it in the home-assistant_v2.db file, which keeps on growing in size. To keep user data backups small the recorder data can be kept in a seperate file, not saved on backups:

  1. Update ~/.homeassistant/configuration.yaml to keep recorder data in seperate file:
    recorder:
      db_url: sqlite:////home/tc/.homeassistant/history.db
    
  2. Add .homeassistant/history.db* to /opt/.xfiletool.lst
  3. Save: backup

It's also possible to set the db_url to a remote (MariaDB for example) location

Install HACS

  1. Install unzip: tce-load -wi unzip
  2. Download latest package: wget https://github.com/hacs/integration/releases/latest/download/hacs.zip
  3. Create directory: mkdir -p ~/.homeassistant/custom_components/hacs
  4. Unzip package: unzip hacs.zip -d ~/.homeassistant/custom_components/hacs
  5. Clean up the home directory
  6. Restart Home Assistant
  7. Go to Settings > Devices & services > Add integration, and add HACS
  8. Check if everything is installed correctly
  9. Save: backup

Update Home Assistant

If Home Assistant needs to be updated later on:

  1. Stop the running Home Assistant process
  2. Upgrade: uv tool upgrade homeassistant
  3. Save: backup
  4. Reboot: sudo reboot
@wootmasterslick
Copy link

Great guide, much simpler than the last one. 😁
Looks to be running fine when I start it manually with the command. But upon boot it doesnt start.
When I run the startup script the su command in it promps for user password. I think I also see password error during boot sequence. Any ideas?

@BillyNate
Copy link
Author

Yes, simpler and faster 😊

Something might be different from piCorePlayer to vanilla piCore.
Maybe you don't need su - tc -c "uv tool run --from homeassistant hass -c /home/tc/.homeassistant", but uv tool run --from homeassistant hass -c /home/tc/.homeassistant is enough.
The su - tc part is because piCore executes the bootlocal.sh as root, not at tc, but we want the uv tool run ... command to be run as tc.
(At https://forums.lyrion.org/forum/user-forums/linux-unix/103403-picoreplayer-root-sudo-access is says there's no direct root access)

Is the default piCorePlayer user tc? Or is this also set to something different? In that case you may need to change the /home/tc path as well.

@wootmasterslick
Copy link

Ok Billy, stupid me finally figured out what I was doing wrong. I appended the start hass command to the end of bootlocal.sh but shouldnt have.
I had to put it before the pcp_startup script.

also I learned what putting the & at the end of the line means in a script….

in addition I modded the hassboot command to
sudo su - tc -c "screen -S HASS -d -m uv tool run --from homeassistant hass -c /home/tc/.homeassistant"

Dont know if it makes it better but I can check into the terminal now.

thanks for your guide, and help!

@BillyNate
Copy link
Author

Good to hear you found the solution! We're never too old to learn 😊
Good luck on your future endeavors with the Pi 🤞

@wootmasterslick
Copy link

wootmasterslick commented Nov 30, 2025

May I ask why you add
homeassistant/home-assistant.log*, .homeassistant/tts, .homeassistant/deps, .homeassistant/.db-wal & .homeassistant/.db-shm to /opt/.xfiletool.lst

and
Add .homeassistant/history.db*
to /opt/.xfiletool.lst

it kind of results into linux not backing up any history data, am I correct?
(For me it resulted into hass not retrieving the history data.)
Also it looks like it impacts dependencies, as I see now that a number of integrations to fail on restart (I have to manually reload them to work)
I was thinking about removing these from the file, what would be the impact?

would it be an option to save the history db in
etc/sysconfig/tcedir/persistent/uv
Would it then stay after reboots and not need backup?

Excuse all my questions, I am just trying to learn :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment