from datetime import datetime


def read_raw(omega):
    """Read the raw temperature, humidity and dewpoint values from an OMEGA iServer.

    Parameters
    ----------
    omega : :class:`msl.equipment.record_types.EquipmentRecord`
        The Equipment Record of an OMEGA iServer.

    Returns
    -------
    :class:`str`
        The serial number of the OMEGA iServer.
    :class:`dict`
        The data.
    """
    nprobes = omega.connection.properties.get('nprobes', 1)
    nbytes = omega.connection.properties.get('nbytes')

    error = None
    try:
        cxn = omega.connect()
        thd = cxn.temperature_humidity_dewpoint(probe=1, nbytes=nbytes)
        if nprobes == 2:
            thd += cxn.temperature_humidity_dewpoint(probe=2, nbytes=nbytes)
        cxn.disconnect()
    except Exception as e:
        error = str(e)
        thd = [None] * (nprobes * 3)

    now_iso = datetime.now().replace(microsecond=0).isoformat(sep='T')
    data = {
        'error': error,
        'alias': omega.alias,
        'datetime': now_iso,
        'report_number': None,
    }
    if len(thd) == 3:
        data.update({
            'temperature': thd[0], 'humidity': thd[1], 'dewpoint': thd[2]
        })
    else:
        data.update({
            'temperature1': thd[0], 'humidity1': thd[1], 'dewpoint1': thd[2],
            'temperature2': thd[3], 'humidity2': thd[4], 'dewpoint2': thd[5]
        })

    return omega.serial, data