Use hostname

This commit is contained in:
Otto Winter 2018-11-23 23:55:47 +01:00
parent a6f1e92c20
commit ab47775475
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E

View file

@ -452,11 +452,12 @@ def _get_mqtt_config_impl():
'X-HASSIO-KEY': os.getenv('HASSIO_TOKEN'),
}
req = requests.get('http://hassio/services/mqtt', headers=headers)
mqtt_config = req.json()['data']
mqtt_config = requests.get('http://hassio/services/mqtt', headers=headers).json()['data']
info = requests.get('http://hassio/info', headers=headers).json()['data']
return {
'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', ''),
'password': mqtt_config.get('password', '')
}