human
I wrote the below code

    import pyloopenergy
    elec_config = config.get(CONF_ELEC)
    gas_config = config.get(CONF_GAS)
    controller = pyloopenergy.LoopEnergy(elec_config.get(CONF_ELEC_SERIAL), elec_config.get(CONF_ELEC_SECRET), gas_config.get(CONF_GAS_SERIAL), gas_config.get(CONF_GAS_SECRET), gas_config.get(CONF_GAS_TYPE), gas_config.get(CONF_GAS_CALORIFIC))
    def stop_loopenergy(event):
        'Shutdown    loopenergy    thread    on    exit.'
        _LOGGER.info('Shutting    down    loopenergy')
        controller.terminate()
    hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_loopenergy)
    sensors = [LoopEnergyElec(controller)]
    if gas_config.get(CONF_GAS_SERIAL):
        sensors.append(LoopEnergyGas(controller))
    add_devices(sensors)

What's a good function header?
 Here's a good function header?
assistant
#Here's a good function header.

def setup_platform(hass, config, add_devices, discovery_info=None):