import base64


def decode_payload(raw):
    """Parses the payload and returns the decoded pair (temperature, humidity)
    
    datasheet: http://www.objenious.com/wp-content/uploads/2016/10/RHF-DS01588Outdoor-IP64-Tempratrure-and-Humidity-LoRaWAN-Sensor-RHF1S001_V1.3.pdf
    """
    p = base64.b64decode(raw)
    raw_t = int.from_bytes(p[1:3], byteorder='little', signed=False)
    raw_h = p[3]
    t = (175.72 * raw_t) / (2**16) - 46.85
    h = (125    * raw_h) / (2**8)  - 6
    return (t, h)