Skip to content

hassio-addons/bashio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Home Assistant Community Add-ons: Bashio

GitHub Release Project Stage License

GitHub Actions Project Maintenance GitHub Activity

Discord

Sponsor Frenck via GitHub Sponsors

Support Frenck on Patreon

About

Bashio is a bash function library for use with Home Assistant add-ons.

It contains a set of commonly used operations and can be used to be included in add-ons to reduce code duplication across add-ons and therefore making it easier to develop and maintain add-ons.

Main goals:

  • Reduce the number of operations needed in add-ons.
  • Reduce the amount of code needed in add-ons.
  • Make add-on code more readable.
  • Providing a trusted and tested code base.

Quicker add-on development, by allowing you to focus on the add-on logic instead of other things.

Installation

The library is installed in the Home Assistant Community Add-ons base images and the official Home Assistant base images.

Currently available base images:

Using those images as the base for your Home Assistant add-on will provide this function library out of the box. Our base images are updated frequently and provide the minimal needed base image for a great add-on.

If you want to add Bashio to your own images, please take a look at the Dockerfile of the above base images to see how they are added at build time.

Configuration

Configuring a Bash script to use the Bashio library is fairly easy. Simply replace the shebang of your script file, from bash to bashio.

Before example:

#!/usr/bin/env bash
set -e

CONFIG_PATH=/data/options.json

USERNAME=$(jq --raw-output '.username // empty' $CONFIG_PATH)

echo "${USERNAME}"

After example with Bashio:

#!/usr/bin/env bashio

USERNAME=$(bashio::config 'username')

bashio::log.info "${USERNAME}"

Functions

Bashio has more than 250+ functions available: communicating with the Supervisor API, Have I Been Pwned, file system, logging, configuration handling and a lot more!

The best way to get around would be by looking at the different modules available in the lib folder. Each module has its own file, and each function has been documented inside the codebase.

Furthermore, Bashio is used by the Home Assistant Community Add-ons project, those add-ons will be a great resource of practical examples.

Known issues and limitations

  • Some parts of the Supervisor API are not implemented yet.

Changelog & Releases

This repository keeps a change log using GitHub's releases functionality. The format of the log is based on Keep a Changelog.

Releases are based on Semantic Versioning, and use the format of MAJOR.MINOR.PATCH. In a nutshell, the version will be incremented based on the following:

  • MAJOR: Incompatible or major changes.
  • MINOR: Backwards-compatible new features and enhancements.
  • PATCH: Backwards-compatible bugfixes and package updates.

Support

Got questions?

You have several options to get them answered:

Contributing

This is an active open-source project. We are always open to people who want to use the code or contribute to it.

We have set up a separate document containing our contribution guidelines.

Thank you for being involved! 😍

Authors & contributors

The original setup of this repository is by Franck Nijhof.

For a full list of all authors and contributors, check the contributor's page.

License

MIT License

Copyright (c) 2019-2024 Franck Nijhof

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.