mirror of
https://github.com/esphome/esphome.git
synced 2025-01-18 10:25:56 +01:00
Use hostname
This commit is contained in:
parent
a6f1e92c20
commit
ab47775475
1 changed files with 4 additions and 3 deletions
|
@ -452,11 +452,12 @@ def _get_mqtt_config_impl():
|
||||||
'X-HASSIO-KEY': os.getenv('HASSIO_TOKEN'),
|
'X-HASSIO-KEY': os.getenv('HASSIO_TOKEN'),
|
||||||
}
|
}
|
||||||
|
|
||||||
req = requests.get('http://hassio/services/mqtt', headers=headers)
|
mqtt_config = requests.get('http://hassio/services/mqtt', headers=headers).json()['data']
|
||||||
mqtt_config = req.json()['data']
|
info = requests.get('http://hassio/info', headers=headers).json()['data']
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'ssl': mqtt_config['ssl'],
|
'ssl': mqtt_config['ssl'],
|
||||||
'host': mqtt_config['host'] + ':' + str(mqtt_config['port']),
|
'host': info['hostname'] + '.local:' + str(mqtt_config['port']),
|
||||||
'username': mqtt_config.get('username', ''),
|
'username': mqtt_config.get('username', ''),
|
||||||
'password': mqtt_config.get('password', '')
|
'password': mqtt_config.get('password', '')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue