Skip to content

Commit

Permalink
MQTT autodiscovery
Browse files Browse the repository at this point in the history
  • Loading branch information
mihsu81 committed Aug 19, 2024
1 parent 18b9fca commit a05aa23
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
8 changes: 8 additions & 0 deletions theengsgateway/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [1.11.4]
### What's Changed
Add autodiscovery of MQTT connection settings if the Mosquito Broker Add-on is running and configured.

## [1.11.3]
### What's Changed
Adjust how BLACKLIST & WHITELIST are inserted

## [1.11.2]
### What's Changed
Add missing option TLS_INSECURE
Expand Down
2 changes: 1 addition & 1 deletion theengsgateway/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
2. Enter `https://github.com/mihsu81/addon-theengsgw` in the box and click on "Add".
3. You should now see "TheengsGateway HA Add-on" at the bottom list.
4. Click on "TheengsGateway", then click "Install".
5. Under the "Configuration" tab, change the settings appropriately (at least MQTT parameters), see [Parameters](#parameters).
5. Under the "Configuration" tab, change the settings appropriately (now the MQTT connection settings are automatically discovered if you have the Moquitto Broker Add-on running and configured), see [Parameters](#parameters).
6. Start the Add-on.

## Parameters
Expand Down
2 changes: 1 addition & 1 deletion theengsgateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG BUILD_FROM
FROM $BUILD_FROM
LABEL io.hass.version="1.11.3" io.hass.type="addon" io.hass.arch="armv7|armhf|aarch64|i386|amd64"
LABEL io.hass.version="1.11.4" io.hass.type="addon" io.hass.arch="armv7|armhf|aarch64|i386|amd64"
RUN apt-get update && apt-get upgrade -y && \
apt-get install --no-install-recommends -y build-essential bluez python3-pip python3-dev && \
pip3 install --extra-index-url=https://www.piwheels.org/simple TheengsGateway==1.5.0
Expand Down
3 changes: 2 additions & 1 deletion theengsgateway/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "TheengsGateway",
"version": "1.11.3",
"version": "1.11.4",
"slug": "theengsgw",
"description": "TheengsGateway HA Add-on",
"url": "https://github.com/mihsu81/addon-theengsgw",
Expand All @@ -13,6 +13,7 @@
"privileged": ["NET_ADMIN", "SYS_ADMIN"],
"host_dbus": true,
"map": ["ssl:ro"],
"services": ["mqtt:want"],
"options": {
"MQTT_HOST": "localhost",
"MQTT_USERNAME": "",
Expand Down
20 changes: 16 additions & 4 deletions theengsgateway/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@ CONFIG="/root/theengsgw.conf"
bashio::log.info "Creating TheengsGateway configuration..."

# Create TheengsGateway config
MQTT_HOST=$(bashio::config 'MQTT_HOST')
MQTT_USERNAME=$(bashio::config 'MQTT_USERNAME')
MQTT_PASSWORD=$(bashio::config 'MQTT_PASSWORD')
MQTT_PORT=$(bashio::config 'MQTT_PORT')
if bashio::services.available "mqtt"; then
MQTT_HOST=$(bashio::services "mqtt" "host")
MQTT_PASSWORD=$(bashio::services "mqtt" "password")
MQTT_PORT=$(bashio::services "mqtt" "port")
MQTT_USERNAME=$(bashio::services "mqtt" "username")
else
bashio::log.info "The MQTT Add-on is not available."
bashio::log.info "This is not a problem if you are using an external MQTT broker."
bashio::log.info "If you are using the Home Assistant Mosquitto Broker Add-on, try restarting it, and then restart this addon."
bashio::log.info "For an external broker, make sure you fill in the mqtt connection settings, and restart the addon."
MQTT_HOST=$(bashio::config 'MQTT_HOST')
MQTT_USERNAME=$(bashio::config 'MQTT_USERNAME')
MQTT_PASSWORD=$(bashio::config 'MQTT_PASSWORD')
MQTT_PORT=$(bashio::config 'MQTT_PORT')
fi

MQTT_PUB_TOPIC=$(bashio::config 'MQTT_PUB_TOPIC')
MQTT_SUB_TOPIC=$(bashio::config 'MQTT_SUB_TOPIC')
MQTT_PRE_TOPIC=$(bashio::config 'MQTT_PRE_TOPIC')
Expand Down

0 comments on commit a05aa23

Please sign in to comment.