Skip to content

Instantly share code, notes, and snippets.

@kchiem
Created March 22, 2023 09:47
Show Gist options
  • Save kchiem/dcff9b0fb4faa3cc0b454e43894f0efc to your computer and use it in GitHub Desktop.
Save kchiem/dcff9b0fb4faa3cc0b454e43894f0efc to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
##
## Run this inside your Home Assistant docker container to update the files
## needed for https://github.com/Blackymas/NSPanel_HA_Blueprint. Eg.
##
## $ docker exec -it homeassistant bash
## # bash -c "$(wget -qO - <raw gist url>)"
##
# exit immediately on errors
set -e
latest=$(curl --silent https://api.github.com/repos/Blackymas/NSPanel_HA_Blueprint/releases/latest | jq -r .tag_name)
read -p "Update to version $latest? (y/n) " yn
case $yn in
[Yy]) ;;
*) exit;;
esac
tmpdir=$(mktemp -d)
pushd "$tmpdir" >/dev/null
archive="https://github.com/Blackymas/NSPanel_HA_Blueprint/archive/refs/tags/$latest.tar.gz"
echo - downloading
curl -L# "$archive" | tar xzf -
dl="$tmpdir/NSPanel_HA_Blueprint-$latest"
echo - archive extracted into "$dl"
echo - updating nspanel_blueprint.yaml
cp $dl/nspanel_blueprint.yaml /config/blueprints/automation/Blackymas/.
for tft in nspanel_{eu,us}.tft; do
if [ -f /config/www/"$tft" ]; then
echo - updating http://homeassistant.local:8123/local/$tft
cp $dl/$tft /config/www/.
fi
done
echo - cleaning up
popd >/dev/null
rm -r "$tmpdir"
echo - you need to restart HA and update your NSPanels in ESPHome now
@kchiem
Copy link
Author

kchiem commented Mar 22, 2023

$ docker exec -it homeassistant bash
# bash -c "$(wget -qO - https://gist.github.com/kchiem/dcff9b0fb4faa3cc0b454e43894f0efc/raw/b39d6228d9b74505d1415c4f747dc5a65f35c0a8/update-blackymas-nspanel-ha-blueprint.sh)"

The output should look something like this:

Update to version v.3.2? (y/n) y
- downloading
                          -=O=-                     #    #    #    #
- archive extracted into /tmp/tmp.MJijNa/NSPanel_HA_Blueprint-v.3.2
- updating nspanel_blueprint.yaml
- updating http://homeassistant.local:8123/local/nspanel_us.tft
- cleaning up
- you need to restart HA and update your NSPanels in ESPHome now

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