mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-01 05:14:04 +02:00
mqtt autodiscovery
This commit is contained in:
@@ -18,8 +18,20 @@ See its github for all informations : https://github.com/m4dm4rtig4n/enedisgatew
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Install, then start the addon a first time to initialize the templates.
|
Install, then start the addon a first time to initialize the templates.
|
||||||
Everything is configured using the config.yaml file found in /config/enedisgateway2mqtt/enedisgateway2mqtt.conf.
|
|
||||||
|
Options can be configured through two ways :
|
||||||
|
|
||||||
|
- Addon options
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
CONFIG_LOCATION: /config/enedisgateway2mqtt/enedisgateway2mqtt.conf # Sets the location of the config.yaml (see below)
|
||||||
|
mqtt_autodiscover: true # Shows in the log the detail of the mqtt local server (if available). It can then be added to the config.yaml file.
|
||||||
|
TZ: Europe/Paris # Sets a specific timezone
|
||||||
|
```
|
||||||
|
|
||||||
|
- Config.yaml
|
||||||
|
Everything is configured using the config.yaml file found in /config/enedisgateway2mqtt/enedisgateway2mqtt.conf.
|
||||||
|
|
||||||
The complete list of options can be seen here : https://github.com/m4dm4rtig4n/enedisgateway2mqtt#environment-variable
|
The complete list of options can be seen here : https://github.com/m4dm4rtig4n/enedisgateway2mqtt#environment-variable
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
{
|
{
|
||||||
"arch": [
|
"arch": ["aarch64", "amd64", "armv7", "armhf"],
|
||||||
"aarch64",
|
|
||||||
"amd64",
|
|
||||||
"armv7",
|
|
||||||
"armhf"
|
|
||||||
],
|
|
||||||
"description": "use Enedis Gateway API to send data in your MQTT Broker (latest channel)",
|
"description": "use Enedis Gateway API to send data in your MQTT Broker (latest channel)",
|
||||||
"map": [
|
"map": ["config:rw"],
|
||||||
"config:rw"
|
|
||||||
],
|
|
||||||
"name": "Enedisgateway2mqtt",
|
"name": "Enedisgateway2mqtt",
|
||||||
"options": {
|
"options": {
|
||||||
"CONFIG_LOCATION": "/config/enedisgateway2mqtt/config.yaml",
|
"CONFIG_LOCATION": "/config/enedisgateway2mqtt/config.yaml",
|
||||||
|
"mqtt_autodiscover": false,
|
||||||
"TZ": "Europe/Paris"
|
"TZ": "Europe/Paris"
|
||||||
},
|
},
|
||||||
|
"services": ["mqtt:want"],
|
||||||
"schema": {
|
"schema": {
|
||||||
"CONFIG_LOCATION": "str",
|
"CONFIG_LOCATION": "str",
|
||||||
|
"mqtt_autodiscover": "bool",
|
||||||
"TZ": "str?"
|
"TZ": "str?"
|
||||||
},
|
},
|
||||||
"slug": "enedisgateway2mqtt",
|
"slug": "enedisgateway2mqtt",
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env bashio
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# Autodiscover mqtt #
|
||||||
|
#####################
|
||||||
|
|
||||||
|
if bashio::config.true 'mqtt_autodiscover'; then
|
||||||
|
bashio::log.info "mqtt_autodiscover is defined in options, attempting autodiscovery..."
|
||||||
|
# Check if available
|
||||||
|
if ! bashio::services.available "mqtt"; then bashio::exit.nok "No internal MQTT service found. Please install Mosquitto broker"; fi
|
||||||
|
# Get variables
|
||||||
|
bashio::log.info "... MQTT service found, fetching server detail (you can enter those manually in your config file) ..."
|
||||||
|
export MQTT_HOST=$(bashio::services mqtt "host")
|
||||||
|
export MQTT_PORT=$(bashio::services mqtt "port")
|
||||||
|
export MQTT_SSL=$(bashio::services mqtt "ssl")
|
||||||
|
export MQTT_USERNAME=$(bashio::services mqtt "username")
|
||||||
|
export MQTT_PASSWORD=$(bashio::services mqtt "password")
|
||||||
|
# Export variables
|
||||||
|
for variables in "MQTT_HOST=$MQTT_HOST" "MQTT_PORT=$MQTT_PORT" "MQTT_SSL=$MQTT_SSL" "MQTT_USERNAME=$MQTT_USERNAME" "MQTT_PASSWORD=$MQTT_PASSWORD"; do
|
||||||
|
[ -f /etc/services.d/*/*run* ] && sed -i "1a export $variables" /etc/services.d/*/*run*
|
||||||
|
[ -f /scripts/*run* ] && sed -i "1a export $variables" /scripts/*run*
|
||||||
|
# Log
|
||||||
|
bashio::log.blue "$variables"
|
||||||
|
done
|
||||||
|
fi
|
||||||
@@ -18,6 +18,18 @@ See its github for all informations : https://github.com/yukulehe/gazpar2mqtt
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
|
Options can be configured through two ways :
|
||||||
|
|
||||||
|
- Addon options
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
CONFIG_LOCATION: /config/gazpar2mqtt/config.yaml # Sets the location of the config.yaml (see below)
|
||||||
|
mqtt_autodiscover: true # Shows in the log the detail of the mqtt local server (if available). It can then be added to the config.yaml file.
|
||||||
|
TZ: Europe/Paris # Sets a specific timezone
|
||||||
|
```
|
||||||
|
|
||||||
|
- Config.yaml
|
||||||
|
|
||||||
Configuration is done by customizing the config.yaml that can be found in /config/gazpar2mqtt/config.yaml
|
Configuration is done by customizing the config.yaml that can be found in /config/gazpar2mqtt/config.yaml
|
||||||
|
|
||||||
The complete list of options can be seen here : https://github.com/yukulehe/gazpar2mqtt
|
The complete list of options can be seen here : https://github.com/yukulehe/gazpar2mqtt
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
#####################
|
#####################
|
||||||
|
|
||||||
if bashio::config.true 'mqtt_autodiscover'; then
|
if bashio::config.true 'mqtt_autodiscover'; then
|
||||||
bashio::log.info "mqtt_autodiscover is defined in options, attemption autodiscovery..."
|
bashio::log.info "mqtt_autodiscover is defined in options, attempting autodiscovery..."
|
||||||
# Check if available
|
# Check if available
|
||||||
if ! bashio::services.available "mqtt"; then bashio::exit.nok "No internal MQTT service found. Please install Mosquitto broker"; fi
|
if ! bashio::services.available "mqtt"; then bashio::exit.nok "No internal MQTT service found. Please install Mosquitto broker"; fi
|
||||||
# Get variables
|
# Get variables
|
||||||
bashio::log.info "... MQTT service found, fetching server detail ..."
|
bashio::log.info "... MQTT service found, fetching server detail (you can enter those manually in your config file) ..."
|
||||||
export MQTT_HOST=$(bashio::services mqtt "host")
|
export MQTT_HOST=$(bashio::services mqtt "host")
|
||||||
export MQTT_PORT=$(bashio::services mqtt "port")
|
export MQTT_PORT=$(bashio::services mqtt "port")
|
||||||
export MQTT_SSL=$(bashio::services mqtt "ssl")
|
export MQTT_SSL=$(bashio::services mqtt "ssl")
|
||||||
|
|||||||
Reference in New Issue
Block a user