Last active
December 9, 2023 21:32
-
-
Save zxdavb/d898e594091753d703c858c9accc59d2 to your computer and use it in GitHub Desktop.
A script to update 'secondary' evohome custom_components after updating HA core
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Based on the description here: | |
# https://github.com/zxdavb/evohome-async/wiki/Hass:-Multiple-Evohome-Locations | |
# This script is tested on Home Assistant OS. | |
# The script should be placed in this location: /config/custom_components/ and run from there. | |
# Run the script once every time you have updated the HA core. | |
# How many extra copies of the integration do you want? | |
INSTANCES=1 | |
HA_VERSION=`ha core info | grep "version:" | cut -d' ' -f2` | |
# These only need to be executed once | |
if [ ! -d "core" ] | |
then | |
git clone --filter=blob:none --sparse https://github.com/home-assistant/core | |
git -C core sparse-checkout add homeassistant/components/evohome | |
fi | |
# Update git core folder with correct HA version | |
echo "Updating git core folder to current HA version..." | |
git -C core fetch --all | |
git -C core checkout $HA_VERSION | |
# Delete all old evohome folders | |
echo "Removing all evohome_x folders..." | |
rm -rf evohome_* | |
# Create all new evohome instances | |
for i in $(seq $INSTANCES) | |
do | |
echo "Creating evohome_$i/" | |
# Copy the evohome folder | |
cp -r core/homeassistant/components/evohome evohome_$i | |
echo "Updating files in evohome_$i/" | |
# Update the files within the integration with proper values | |
sed -i "/domain/ s/evohome/evohome_$i/" evohome_$i/manifest.json | |
sed -i '/{/a \ \ "version": "0.0.1",' evohome_$i/manifest.json | |
sed -i "/DOMAIN/ s/evohome/evohome_$i/" evohome_$i/const.py | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment