human
I wrote the below code

    if (discovery_info is None):
        return
    gateways = hass.data.get(mysensors.MYSENSORS_GATEWAYS)
    if (not gateways):
        return
    platform_devices = []
    for gateway in gateways:
        pres = gateway.const.Presentation
        set_req = gateway.const.SetReq
        map_sv_types = {pres.S_DOOR: [set_req.V_ARMED], pres.S_MOTION: [set_req.V_ARMED], pres.S_SMOKE: [set_req.V_ARMED], pres.S_LIGHT: [set_req.V_LIGHT], pres.S_LOCK: [set_req.V_LOCK_STATUS], pres.S_IR: [set_req.V_IR_SEND]}
        device_class_map = {pres.S_DOOR: MySensorsSwitch, pres.S_MOTION: MySensorsSwitch, pres.S_SMOKE: MySensorsSwitch, pres.S_LIGHT: MySensorsSwitch, pres.S_LOCK: MySensorsSwitch, pres.S_IR: MySensorsIRSwitch}
        if (float(gateway.protocol_version) >= 1.5):
            map_sv_types.update({pres.S_BINARY: [set_req.V_STATUS, set_req.V_LIGHT], pres.S_SPRINKLER: [set_req.V_STATUS], pres.S_WATER_LEAK: [set_req.V_ARMED], pres.S_SOUND: [set_req.V_ARMED], pres.S_VIBRATION: [set_req.V_ARMED], pres.S_MOISTURE: [set_req.V_ARMED]})
            map_sv_types[pres.S_LIGHT].append(set_req.V_STATUS)
            device_class_map.update({pres.S_BINARY: MySensorsSwitch, pres.S_SPRINKLER: MySensorsSwitch, pres.S_WATER_LEAK: MySensorsSwitch, pres.S_SOUND: MySensorsSwitch, pres.S_VIBRATION: MySensorsSwitch, pres.S_MOISTURE: MySensorsSwitch})
        if (float(gateway.protocol_version) >= 2.0):
            map_sv_types.update({pres.S_WATER_QUALITY: [set_req.V_STATUS]})
            device_class_map.update({pres.S_WATER_QUALITY: MySensorsSwitch})
        devices = {}
        gateway.platform_callbacks.append(mysensors.pf_callback_factory(map_sv_types, devices, device_class_map, add_devices))
        platform_devices.append(devices)
    def send_ir_code_service(service):
        'Set    IR    code    as    device    state    attribute.'
        entity_ids = service.data.get(ATTR_ENTITY_ID)
        ir_code = service.data.get(ATTR_IR_CODE)
        if entity_ids:
            _devices = [device for gw_devs in platform_devices for...

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

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