Allow blueprint upgrades

The .conf file needs to be created in the same directory as the script, and you need to create a long lived access token, the token can be created in your HA profile settings, all the way at the bottom.
Paste the token (long blob of text) in the conf file and you should be good to go.
I’ve put a link in the github readme to some documentation from HA but it’s really aimed at developers, I’ll try to find a better link or write it up myself.

The server http://localhost:8123 should be good for standard installs.

1 Like

still running into issues with spaces… turns out when i run the command manually over ssh the call to wget is truly wget, but when run from service-call the busybox-wget is used…

and there seems to be a difference in handling the spaces in url’s between the two…

update:
i’m switching wget for curl, which has also issues with spaces, but at least in both ssh and service-call executions the same curl is used…
(and issues with spaces is just that they need to be url-encoded before being sent to curl, which would also be needed for the busybox-wget version)

update 2:
i switched wget for curl, and for now everything seems to work even with spaces, and it doesn’t matter if the script is run from the terminal or from an automation

1 Like

The latest version has become much slower. I thought it was hung, but it just took several minutes between blueprints. I have the .conf installed now as well.

This one popped this error. Then the script exited.

-> blueprint up-2-date

> ./script/DefenestrateIT/Another Light Blueprint-Script [Lone-Wolf].yaml
-> source_url: https://gist.github.com/DefenestrateIT/b5a5830c5eb990e651622efda90b4600
-! fix github gist url to raw
-> fixed source_url: https://gist.githubusercontent.com/DefenestrateIT/b5a5830c5eb990e651622efda90b4600/raw/Another Light Blueprint-Script [Lone-Wolf].yaml
-> download blueprint
-! something went wrong while downloading, exiting...

I’m not sure if anyone would care that this thread is a bit different from the main Topic. Being that it started as a FR and we have diverged out of HA and into shell scripts as an answer. They can be sensitive about these things.
A suggestion could be to open a Discussion on the GitHub repo to continue the troubleshooting? Just a thought.

the problem is the [ and ] symbols… so it would be an easy fix to add those to the urlencoding part…
but the problem wil keep emerging when “weird” characters are used in the filenames… problem was that if i urlencoded the whole URL it also changed the :// and all slashes, which curl really wasn’t happy about…

so i’ll look into a more complete url-encoding function which doesn’t break curl

as for the speed, i don’t know where that comes from, there weren’t any changes which should impact speed that much… only thing i can think of is that maybe you are getting a time-out or something on the notification call to HA ? have you received a notification in HA ?

i’ll add a timestamp to the logging when in debug mode, which would make it easier to find out where the time is spent.

also, i enabled the discussions page on github, so we could continue there with general troubleshooting, since i agree we are getting a bit “off-topic”

1 Like

Further discussion specific to the update script designed by @koter84 should be moved to here:

3 Likes

Is there any HA developer interest in baking in a Blueprint update feature? I’m fairly new to HA, and found some awesome Blueprints. One developer rapidly releases updates and I’d love a one click method to do a version update. HACS and all core related updates function this way, and Blueprints need to as well.

1 Like

I agree, but I have heard it has been written and rejected before because of the chance that the new blueprint version breaks the users config. It was pointed out that this is what hacs does, but that didn’t convince anyone. I use the shell script above and have very few problems with it.

Sounds like this may be the discussion you’re thinking of:

Doesn’t read to me like it was flat-out refused, just seemed like there were some reasonable questions raised as part of the discussion, and never really got followed up on.

Though I don’t see HACS in there so maybe that was a separate discussion.

Yes, probably. They talked about it in a live stream as well.
So of course it is possible for some goof to blow up peoples automations by changing the existing !inputs, but if the !inputs are left and new ones added, like I do, or if the change has nothing to do with !inputs, then updates work fine.
I think if they parse the old one and make sure the !inputs that are in the old one are in the new one, it shouldn’t break things.
And besides in this latest release they don’t hide broken automations like they used to. Being able to find them easily is a big part of fixing them.

1 Like

I have an issue with a blueprint update as source as no .yaml extension to file.

Is it possible to exclude some blueprint ?

This is not an area to get support.
It appears you are looking for support in a specific blueprint.
You should go to the topic for that specific blueprint in the exchange and ask your question there or put in an issue in that github if you think there is a problem.

You’re right, i will do it

Is it possible to just notify that there is an update instead of automatically updating the blueprint?
That way, I know there is an update and go the blueprint creator page and manually update it?

You can run the ‘koter’ software and not tell it to update. It will leave a notification for you that the linked copy is different that yours at that point.
Allow blueprint upgrades - #48 by Sir_Goodenough.

1 Like

I have been trying this script for a couple of days now and the notifications work great.
However, there is no updated version of the blueprint when I go to check on the author’s github page.

I do not understand your question, but I will guess.
The blueprint author does not report an updated version of their blueprint, but the Koter script wants to update it?

So when you import a blueprint, HA reads the code and changes some things to a format it likes better and stores that. Some of the text formatting is line-returns, spacing, and stuff. The Koter script will read the original authors stored code character by character and if that has 1 character different from what you have stored, it says there is an update to be loaded. It is OK for you to pull in this version as it is exactly as the author is presenting as their final product, and it is generally easier to read should you need to dive into the code.
If you have changed the original authors blueprint code to suit your own system better (the original blueprint, not the automation/script you create from the blueprint) this update process will revert that, so you need to remove the source_url line so that doesn’t happen and you are on your own for updates after that.

The only times I have had problems with the software is if the source_url line in the copy I have stored locally is wrong, or if I am editing a blueprint and the scheduled run of the update software happens and wiped my edits. I have it running in the automatic update mode on a schedule every day and I have it update my scripts and automations after an update to make the new code take effect. A bit dangerous, but sometimes it’s OK (for me) ‘livin on the edge…’ (:musical_score: as Aerosmiith once said :microphone:).
My system is also backing the config up to github, so if something goes wrong with that, I can revert the change and go to the previous.

####################################################
# Check for backend updates                        #
####################################################
- id: 651ccea3-8a0f-4ddd-a07a-b2235ac5426d
  alias: Backend Update
  description: "Keep stuff up to date"
  initial_state: on
  trigger:
    - platform: time_pattern
      hours: "11"
      minutes: "59"
      seconds: "59"
  action:
    - alias: Blueprints update
      service: shell_command.blueprints_update
      enabled: true
    - parallel:
      - alias: pull in new blueprint code if any were loaded
        service: automation.reload
      - alias: pull in new blueprint code if any were loaded
        service: script.reload
  mode: single

@luma
I believe that currently home assistant does let you upgrade blueprints now when reimporting, as that is what I did when going to 1.05 for all my automations.

However, there is still no versioning that lets me know that these upgrades are available and no notification/independent check for versioning that is automated (isn’t that the point of home automation?!) for this. I basically just do it when something goes wrong with one of the HASPones. I would love for the other features you requested to be addressed. HACS doesn’t seem to be a viable alternative for things like the HASPOnes because of the custom nature of the blueprints. Most HACS configurations I have seen have much to do with basic functionality for items, not their automations and things that run via automations, but i could be wrong.

They carefully named that update, not upgrade, on purpose so yes no versioning system.

I still just run that software to check the code in the gitrepos for changes 2x a day. If that code changes, it changes mine. If that breaks it, I fix it. None of the blueprints I run is critical path.