human
Here's a good function header given the following:
I wrote the below code

    client_type = config[DOMAIN][CONF_TYPE]
    if (client_type == 'serial'):
        from pymodbus.client.sync import ModbusSerialClient as ModbusClient
        client = ModbusClient(method=config[DOMAIN][CONF_METHOD], port=config[DOMAIN][CONF_PORT], baudrate=config[DOMAIN][CONF_BAUDRATE], stopbits=config[DOMAIN][CONF_STOPBITS], bytesize=config[DOMAIN][CONF_BYTESIZE], parity=config[DOMAIN][CONF_PARITY])
    elif (client_type == 'tcp'):
        from pymodbus.client.sync import ModbusTcpClient as ModbusClient
        client = ModbusClient(host=config[DOMAIN][CONF_HOST], port=config[DOMAIN][CONF_PORT])
    elif (client_type == 'udp'):
        from pymodbus.client.sync import ModbusUdpClient as ModbusClient
        client = ModbusClient(host=config[DOMAIN][CONF_HOST], port=config[DOMAIN][CONF_PORT])
    else:
        return False
    global HUB
    HUB = ModbusHub(client)
    def stop_modbus(event):
        'Stop    Modbus    service.'
        HUB.close()
    def start_modbus(event):
        'Start    Modbus    service.'
        HUB.connect()
        hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_modbus)
        descriptions = load_yaml_config_file(os.path.join(os.path.dirname(__file__), 'services.yaml')).get(DOMAIN)
        hass.services.register(DOMAIN, SERVICE_WRITE_REGISTER, write_register, descriptions.get(SERVICE_WRITE_REGISTER), schema=SERVICE_WRITE_REGISTER_SCHEMA)
        hass.services.register(DOMAIN, SERVICE_WRITE_COIL, write_coil, descriptions.get(SERVICE_WRITE_COIL), schema=SERVICE_WRITE_COIL_SCHEMA)
    def write_register(service):
        'Write    modbus    registers.'
        unit = int(float(service.data.get(ATTR_UNIT)))
        address = int(float(service.data.get(ATTR_ADDRESS)))
        value = service.data.get(ATTR_VALUE)
        if isinstance(value, list):
            HUB.write_registers(unit, address, [int(float(i)) for i in value])
        else:
            HUB.write_register(unit, address, int(float(value)))
    def write_coil(service):
        'Write    modbus    coil.'
       ...

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

def setup(hass, config):