Skip to content

Instantly share code, notes, and snippets.

@varenc
Last active July 15, 2024 12:12
Show Gist options
  • Save varenc/243eeed5622f0e749367b2f9e9d73a38 to your computer and use it in GitHub Desktop.
Save varenc/243eeed5622f0e749367b2f9e9d73a38 to your computer and use it in GitHub Desktop.
Install iCloud3 v3.0.5.2 quick fix for Home Assistant 2024.7.x

This script just automates the fix described in gcobb321/icloud3#356 by @gcobb321 for fixing iCloud v3.0.5.2 compatability with Home Assistant 2024.7.x

I took some attempts to be safe but use at your own risk!

To run it just ssh into your HA server, then fetch the file below and evaluate it with bash.

$ wget "https://gist.githubusercontent.com/varenc/243eeed5622f0e749367b2f9e9d73a38/raw/icloud3_quick_fix.sh"
$ bash icloud3_quick_fix.sh
#!/bin/bash
# This is an automation of the process described here: https://github.com/gcobb321/icloud3/issues/356
# I don't know where a user's homeassistant directory might be so just search the filesystem for the narrowly defined iCloud3 path
# Could update this to check hardcoded paths if those are always well defined.
RECORDER_PREFILTER_PATH="$(find / -type f -path '*/icloud3/support/recorder_prefilter.py' 2>/dev/null)";
MANIFEST_PATH="$(find / -type f -path '*/icloud3/manifest.json' 2>/dev/null)";
if [[ -z "$RECORDER_PREFILTER_PATH" || -z "$MANIFEST_PATH" ]]; then
echo "Could not find the recorder_prefilter.py or manifest.json file. Exiting.";
exit 1;
fi
# make sure there's only one match for each file
if [[ $(echo "$RECORDER_PREFILTER_PATH" | wc -l) -ne 1 || $(echo "$MANIFEST_PATH" | wc -l) -ne 1 ]]; then
echo "Found multiple matches for recorder_prefilter.py or manifest.json. Exiting.";
exit 1;
fi
echo "Found the following files:";
echo " recorder_prefilter.py: $RECORDER_PREFILTER_PATH";
echo " manifest.json: $MANIFEST_PATH";
read -p "Do you want to continue? (y/n) " -n 1 -r
if [[ -z $REPLY ]] || ! echo "$REPLY" | grep -Eq "^[Yy]$"; then # /bin/sh compatible way of doing regex check
echo "Exiting..."
exit 1;
fi
echo
echo "Moving the original recorder_prefilter.py to recorder_prefilter.py.ORIGINAL";
mv -v "$RECORDER_PREFILTER_PATH" "$RECORDER_PREFILTER_PATH.ORIGINAL";
echo "Downloading the new recorder_prefilter.py...";
wget -q https://github.com/gcobb321/icloud3_v3/raw/main/custom_components/icloud3/support/recorder_prefilter.py -O "$RECORDER_PREFILTER_PATH";
echo "Updating the manifest.json file...";
sed -i 's/"version": "3.0.5.2"/"version": "3.0.5.3"/' $MANIFEST_PATH # this just modifies the version number. Or use an editor like `nano`.
echo "Done!"
read -p "Do you want to restart Home Assistant now? (y/n) " -n 1 -r
if [[ -z $REPLY ]] || ! echo "$REPLY" | grep -Eq "^[Yy]$"; then
echo "Exiting... restart Home Assistant manually for changes to take effect.";
exit 1;
fi
echo "Restarting Home Assistant...";
ha core restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment