def generate_config(hass, passwd):
 from homeassistant.components.mqtt import PROTOCOL_311
 config = {'listeners': {'default': {'max-connections': 50000, 'bind': '0.0.0.0:1883', 'type': 'tcp'}, 'ws-1': {'bind': '0.0.0.0:8080', 'type': 'ws'}}, 'auth': {'allow-anonymous': (hass.config.api.api_password is None)}, 'plugins': ['auth_anonymous']}
 if hass.config.api.api_password:
  username = 'homeassistant'
  password = hass.config.api.api_password
  from passlib.apps import custom_app_context
  passwd.write('homeassistant:{}\n'.format(custom_app_context.encrypt(hass.config.api.api_password)).encode('utf-8'))
  passwd.flush()
  config['auth']['password-file'] = passwd.name
  config['plugins'].append('auth_file')
 else:
  username = None
  password = None
 client_config = ('localhost', 1883, username, password, None, PROTOCOL_311)
 return (config, client_config)

def generate_config ( hass , passwd ) : from homeassistant . components . mqtt import PROTOCOL_311 config = { 'listeners' : { 'default' : { 'max-connections' : 50000 , 'bind' : '0.0.0.0:1883' , 'type' : 'tcp' } , 'ws-1' : { 'bind' : '0.0.0.0:8080' , 'type' : 'ws' } } , 'auth' : { 'allow-anonymous' : ( hass . config . api . api_password is None ) } , 'plugins' : [ 'auth_anonymous' ] } if hass . config . api . api_password : username = 'homeassistant' password = hass . config . api . api_password from passlib . apps import custom_app_context passwd . write ( 'homeassistant:{}\n' . format ( custom_app_context . encrypt ( hass . config . api . api_password ) ) . encode ( 'utf-8' ) ) passwd . flush ( ) config [ 'auth' ] [ 'password-file' ] = passwd . name config [ 'plugins' ] . append ( 'auth_file' ) else : username = None password = None client_config = ( 'localhost' , 1883 , username , password , None , PROTOCOL_311 ) return ( config , client_config )
generate a configuration based on current home assistant instance .