zxdavb / evohome-async

An asyncio Python client to access the Evohome web service
http://evohome-client.readthedocs.org/en/latest/
Apache License 2.0
11 stars 11 forks source link

Created a script for creating/updating the "multiple evohome locations" in custom_components. Can you add it to the wiki? #13

Closed Zynth-dev closed 10 months ago

Zynth-dev commented 10 months ago

Hi @zxdavb !

Thanks for helping me out earlier this evening. I have created a shellscript that handles all the steps of "Hass: Multiple Evohome Locations". It supports creating, as well as updating the integration automatically.

Could you add this to the wiki? https://github.com/zxdavb/evohome-async/wiki/Hass:-Multiple-Evohome-Locations#step-6-finally-enable-the-new-integration

#!/bin/bash
#Script name: update_evohome_locations.sh
#Purpose: Create/Update your multiple evohome locations in the folder custom_components/
#Based on the wiki: 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 and run from there: /config/custom_components/
#Run the script when you want to install multiple locations, and 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

  #Update the files within the integration with proper values
  echo "Updating files in evohome_$i/"
  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
zxdavb commented 10 months ago

I am not inclined to - I would just have to keep it up to date, so more work for me.

Why not you create a gist (https://gist.github.com/), and I can attach a reference to that.

When you update the script (if you ever need to), then you keep the gist up-to-date?

Zynth-dev commented 10 months ago

I don't know about gists, so I will read up on that. Alternatively: you could just add the script to the wiki and remove all the other text (steps 1-5). And just maintain the script whenever needed. It does the same, is documented, and is quite easy to follow.

Zynth-dev commented 10 months ago

A gist seems to be a good idea: https://gist.github.com/Zynth-dev/86433ec6fd9e73c47ac0f63442cea56a

zxdavb commented 10 months ago

OK, it is in the Wiki.