human
I wrote the below code

    import soco
    if (DATA_SONOS not in hass.data):
        hass.data[DATA_SONOS] = []
    advertise_addr = config.get(CONF_ADVERTISE_ADDR, None)
    if advertise_addr:
        soco.config.EVENT_ADVERTISE_IP = advertise_addr
    if discovery_info:
        player = soco.SoCo(discovery_info.get('host'))
        if (player.uid in [x.unique_id for x in hass.data[DATA_SONOS]]):
            return
        if player.is_visible:
            device = SonosDevice(player)
            add_devices([device], True)
            hass.data[DATA_SONOS].append(device)
            if (len(hass.data[DATA_SONOS]) > 1):
                return
    else:
        players = None
        hosts = config.get(CONF_HOSTS, None)
        if hosts:
            hosts = (hosts[0] if (len(hosts) == 1) else hosts)
            hosts = (hosts.split(',') if isinstance(hosts, str) else hosts)
            players = []
            for host in hosts:
                players.append(soco.SoCo(socket.gethostbyname(host)))
        if (not players):
            players = soco.discover(interface_addr=config.get(CONF_INTERFACE_ADDR))
        if (not players):
            _LOGGER.warning('No    Sonos    speakers    found')
            return
        hass.data[DATA_SONOS] = [SonosDevice(p) for p in players]
        add_devices(hass.data[DATA_SONOS], True)
        _LOGGER.info('Added    %s    Sonos    speakers', len(players))
    descriptions = load_yaml_config_file(path.join(path.dirname(__file__), 'services.yaml'))
    def service_handle(service):
        'Handle    for    services.'
        entity_ids = service.data.get('entity_id')
        if entity_ids:
            devices = [device for device in hass.data[DATA_SONOS] if (device.entity_id in entity_ids)]
        else:
            devices = hass.data[DATA_SONOS]
        for device in devices:
            if (service.service == SERVICE_JOIN):
                if (device.entity_id != service.data[ATTR_MASTER]):
                    device.join(service.data[ATTR_MASTER])
            elif (service.service ==...

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

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