Tweak MQTT discovery

This commit is contained in:
tsightler
2025-12-07 23:37:37 -05:00
parent 207232171f
commit 1997c56c77
2 changed files with 4 additions and 4 deletions

View File

@@ -21,7 +21,7 @@ if [ -v HASSIO_TOKEN ]; then
export DEBUG=$(bashio::config "debug")
# Export MQTT service discovery data for use within NodeJS process
if bashio::services.available 'mqtt'; then
if bashio::var.has_value "$(bashio::services 'mqtt')"; then
export HAMQTTHOST=$(bashio::services mqtt "host")
export HAMQTTPORT=$(bashio::services mqtt "port")
export HAMQTTUSER=$(bashio::services mqtt "username")

View File

@@ -72,12 +72,12 @@ export default new class Config {
mqttURL.hostname = process.env.HAMQTTHOST
if (mqttURL.hostname === 'localhost' || mqttURL.hostname === '127.0.0.1') {
debug(`Discovered invalid value for MQTT host: ${mqttURL.hostname}`)
debug('Overriding with default alias for Mosquitto MQTT addon')
debug('Overriding with default alias for the Mosquitto addon')
mqttURL.hostname = 'core-mosquitto'
}
} else {
debug('No Home Assistant MQTT service found, using Home Assistant hostname as default')
mqttURL.hostname = process.env.HAHOSTNAME
debug('No Home Assistant MQTT service found, using the default alias for the Mosquitto addon')
mqttURL.hostname = 'core-mosquitto'
}
} else if (mqttURL.protocol === 'mqtts:') {
mqttURL.hostname = process.env.HAHOSTNAME