this script has been moved to its own github repo and can now be found on https://github.com/koter84/HomeAssistant_Blueprints_Update/
Last active
January 27, 2023 14:38
-
-
Save koter84/86790850aa63354bda56d041de31dc70 to your computer and use it in GitHub Desktop.
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 | |
self_file="$0" | |
self_source_url="https://raw.githubusercontent.com/koter84/HomeAssistant_Blueprints_Update/main/blueprints_update.sh" | |
# print info function | |
function _blueprint_update_info | |
{ | |
echo "$@" | |
} | |
# create a temp file for downloading | |
_tempfile=$(mktemp -t blueprints_update.XXXXXX) | |
# start message | |
_blueprint_update_info "> ${self_file}" | |
# update | |
wget -q -O "${_tempfile}" "${self_source_url}" | |
wget_result=$? | |
if [ "${wget_result}" != "0" ] | |
then | |
_blueprint_update_info "! something went wrong while downloading, exiting..." | |
_blueprint_update_info | |
exit | |
fi | |
self_diff=$(diff "${self_file}" "${_tempfile}") | |
if [ "${self_diff}" == "" ] | |
then | |
_blueprint_update_info "-> self up-2-date" | |
else | |
cp "${_tempfile}" "${self_file}" | |
chmod +x "${self_file}" | |
_blueprint_update_info "-! self updated!" | |
exit | |
fi | |
_blueprint_update_info |
i have made a full github repository for this script, which you can find on https://github.com/koter84/HomeAssistant_Blueprints_Update/
i'm currently fixing some errors and adding a couple of features, once i commit that to the new repository i'll update this script to auto-update to that repository.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this @koter84 .I did some initial troubleshooting with you on this and it looks great here.
I've noticed that blueprint filenames that have spaces or non alpha characters get confused and comes back with non-matching filename. I think this worked at one time, it is not now from this gist version anyway.
Another thing that seemed confused was if I add custom- to a source url, it finds it, updates it, but the url is not in the file when it comes back. Instead we get
- source_url:
and a blank which fails syntax in HA. I'm pretty sure that was fine early on as well.I'm thinking perhaps an in-between version is posted here.
Also if there is a way the shell can return a flag if there are updates needed or not would be great. I'm not really wanting to have it just update when I'm not there when it tuns in a timer. I would prefer it runs on the timer, returns some data that we can grab in HA to do a persistent_notification that updates need to be checked. (Webhook with some json message(s), perhaps?)
An enhancement request would be another switch that takes a filename so a single file could be checked or updated as opposed to all.