def parse_sml(response):
    """Parse the json for a SML Hue motion sensor and return the data."""
    if response.type == 'ZLLLightLevel':
        lightlevel = response.state['lightlevel']
        if lightlevel is not None:
            lux = round(float(10 ** ((lightlevel - 1) / 10000)), 2)
            dark = response.state['dark']
            daylight = response.state['daylight']
            data = {'light_level': lightlevel, 'lux': lux, 'dark': dark,
                'daylight': daylight}
        else:
            data = {'light_level': 'No light level data'}
    elif response.type == 'ZLLTemperature':
        if response.state['temperature'] is not None:
            data = {'temperature': response.state['temperature'] / 100.0}
        else:
            data = {'temperature': 'No temperature data'}
    elif response.type == 'ZLLPresence':
        name_raw = response.name
        arr = name_raw.split()
        arr.insert(-1, 'motion')
        name = ' '.join(arr)
        hue_state = response.state['presence']
        if hue_state is True:
            state = 'on'
        else:
            state = 'off'
        data = {'model': 'SML', 'name': name, 'state': state, 'battery':
            response.config['battery'], 'last_updated': response.state[
            'lastupdated'].split('T')}
    return data
