• 2 Posts
  • 6 Comments
Joined 1 year ago
cake
Cake day: June 29th, 2023

help-circle
  • Oh, I backup religiously since Blue failed right after I moved and backup my backups on my laptop as well. (literally failed; I lost everything and had to run photorec and three other tools to pick out everything I’d done for the previous six months, since that I hadn’t copied to a backup on my server because I was prepping to move at the time).

    So far, OTBR is the biggest stopping issue since HA runs it but nothing sticks. I admit, moving zwave is my actual biggest dread; zigbees I can do probably in a weekend, but zwave is such hell to unpair and re-pair (thought it makes up for it by sticking forever). That’s part of the reason I love Thread and Matter; they’re almost as sticky as zwave once they pair, and while pairing them is variable (sometimes fast, sometimes not so much) they repair themselves pretty consistently if the outage is under 24 hours and you can deliberately unpair them fairly easily.


  • I’ve been running Home Assistant for roughly five-six years (Pi, then Blue, now Amber and a second instance on my server for network integrations like nmap and netgear), but since my SmartThings hub was taking care of zigbee/zwave, until now I used HA as a coordinator for every smart device ecosystem I was using (Hue, Wyze, Ring, Blink, Alexa, August, Arlo, et al). Sorry that wasn’t clear.

    While Ive started slowly adding zigbee devices directly, I haven’t started with zwave and thread isn’t working for me yet (OTBR is running but nothing sticks). And I really don’t want to have my hub fail and all my thread/matter devices useless when I don’t have anything that can access them.






  • So it can be done, it just–required a lot of steps and me making a mapping spreadsheet of all the containers. But! Automations and scripts run in the homeassistant container, while when you ssh, you’re going into the ssh addon container which should have been obvious and really was once I finished mapping all the containers.

    Goal: I need /usr/local/bin in the ssh container so I can run scripts over ssh and access my function library script easily without ./path/to/script.

    Summary: ssh into HAOS from the homeassistant container with an HAOS root user (port 22222), run docker exec to get into the ssh addon container, then make your symlinks for /usr/local/bin.

    (Note: this is ridiculously complicated and I know there has to be a better way. But this works so I win.)

    1. Get access to HAOS itself as root: https://developers.home-assistant.io/docs/operating-system/debugging. Verify you can login successfully.
    2. In homeassistant container:
    • a. create an .ssh folder (/config/.ssh)
    • b. add the authorized_keys file you made for step one.
    • c. add the public and private keys you made for step one (should be in the ssh addon container).
    • d. set permissions;
    chmod 600 /config/.ssh/authorized_keys
    chmod 600 /config/.ssh/PRIVATE_KEY
    chmod 644 /config/.ssh/PUBLIC_KEY
    chmod 700 /config/.ssh
    
    • e. In /config/shell_scripts.yaml or wherever you put your shell scripts, add the script you want to use to update /usr/local/bin: UPDATE_BIN_SCRIPT: /config/shell_scripts/UPDATE_BIN_SCRIPT
    • f. Restart HA.
    • g. Check it in Developer Tools->Services

    I have no idea how consistent the ssh addon container name is usually but it’s different on all three of my installs, so insert your container name for SSH_ADDON_CONTAINER_NAME

    Steps: login to HAOS, go into the SSH Container, and do the update. This is horribly messy but hey, it works.

    UPDATE_BIN_SCRIPT

    #!/bin/bash
    
    # OPTIONAL: Update some of the very outdated alpine packages in both homeassistant and the ssh addon (figlet makes cool ascii art of my server
    # name).   You'll need to run it twice; once for the homeassistant container, then again in the ssh container.  Assuming you want to update packages,
    # anyway
    # update homeassistant container packages
    apk add coreutils figlet iproute2 iw jq ncurses procps-ng sed util-linux wireless-tools
    
    # ssh into HAOS and access docker container
    ssh -i /config/.ssh/PRIVATE_KEY -p 22222 root@HA_IP_ADDRESS << EOF
    	docker exec SSH_ADDON_CONTAINER_NAME \
    	bash -c \
           'apk add coreutils figlet iproute2 iw jq ncurses procps-ng sed util-linux wireless-tools; \
    	if [ ! -h /usr/local/bin/SCRIPT1 ]; then echo "SCRIPT1 does not exist"; \
    	ln -s /homeassistant/shell_scripts/SCRIPT1 /usr/local/bin/SCRIPT1; echo "Link created"; \
    	else echo "Link exists";fi; \
    	if [ ! -h /usr/local/bin/SCRIPT2 ]; then echo "SCRIPT2 does not exist"; \
    	ln -s /homeassistant/shell_scripts/SCRIPT2 /usr/local/bin/SCRIPT2; echo "Link created"; \
    	else echo "Link exists";fi'
    EOF
    
    echo "Done"
    

    I am going to feel really stupid when I find out there’s a much easier way.