Add-ons services API (#411)

* Add-ons services API

* Update hassio_addon_communication.md

* Update hassio_addon_communication.md

* ✏️ Tweaks

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
Pascal Vizeli 2020-02-19 09:51:58 +01:00 committed by GitHub
parent 12d1e2646d
commit 32280a2422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,7 +40,27 @@ Add-ons can call some API commands without needing to set `hassio_api: true`:
***Note:*** For Home Assistant API access requirements, see above.
## Services API
We have an internal services API to make services public to other add-ons without the user need to add additional configuration. An add-on can get the full configuration for a service to use and to connect to. The add-on need to mark the usage of a service over his [configuration](hassio_addon_config.md) in order to be able to access a service. All supported services, including its available options, are documented in the [API documentation][supervisor-services-api].
Supported services are:
- mqtt
- mysql
You can use Bashio to get this information for your add-on init as: `bashio::services <service> <query>`
For example:
```bash
MQTT_HOST=$(bashio::services mqtt "host")
MQTT_USER=$(bashio::services mqtt "username")
MQTT_PASSWORD=$(bashio::services mqtt "password")
```
[core-api]: https://www.home-assistant.io/developers/rest_api/
[core-websocket]: https://www.home-assistant.io/developers/websocket_api/
[supervisor-api]: https://github.com/home-assistant/supervisor/blob/master/API.md
[supervisor-addon-api]: https://github.com/home-assistant/supervisor/blob/dev/API.md#restful-for-api-addons
[supervisor-services-api]:https://github.com/home-assistant/supervisor/blob/dev/API.md#services-1