Hass.io Add-on: Upload hassio snapshots to Dropbox

Ive just redesigned the add-on along the lines of our discussion here and pushed version 1.0.0.

See the README for full details, but some highlights:

  • Uploads are triggered via service calls to hassio.addon_stdin, allowing for automations and scripting of Dropbox uploads. Thanks @jchasey for the suggestion.
  • Uploads all .tar files in the backup directory to a specified output path, skipping files that have already been uploaded (No longer uploads entire directory).
  • Start the add-on once and leave it on. It will listen for messages via service calls, as detailed in the README.
    • Note: this means no upload is triggered when the add-on is started, only when a service call is made.

I’ve tested this locally and it’s working great. In the process of this redesign, I had to do a deep-dive into how hassio identifies add-ons for service calls such as stdin, start, stop, etc. I share some details about this in the bottom of the readme. Short version: hassio hashes the installed repository name and uses that as an identifier in the format {REPO_HASH}_{ADDON_SLUG}. @DavidFW1960 I guess this is why you were having trouble starting/stopping the add-on previously.

I think this is a great way to come up with a unique identifier, but I don’t think it’s great that I had to figure that out on my own, manually hash my github url, and now have to document that hashed result for anyone to actually make a service call involving this (or any) add-on whatsoever.

So I have a couple proposed changes for the docs on this issue:

The name have the following format {REPO}-{SLUG}, e.g. local-xy or 3283fh-myaddon

  • This is wrong. It should be _, not -. Here’s the corresponding source code.
  • Since understanding how this hash is generated and being able to produce it for your own repository is required if you’re going to distribute an add-on that uses service calls, it should probably be documented.
    • EDIT: after more reading, you can actually get this repo identifier from a call to the /addons via the hassio API. I think that would be good to document here.

Additionally, I think it’d be great if, through the Home Assistant UI, some sort of mapping of add-on name to identifier could be displayed. Off the top of my head, it seems like it’d be nice to display it as additional service information/documentation below the service selection field in developer tools, as there’s nothing currently there. But I’m unfamiliar with how these are generated and don’t know if it’d be possible.

All this is to say: I haven’t tested it with the hashed slug yet (the repo_id is local when using a local repository), so please let me know if there are problems with service calls.

2 Likes