def get_prop(obj, prop, mytype='str'):
    """Get a property of a dict, for example device['uptime'], and handle None-values."""
    if mytype == 'str':
        if prop in obj:
            if obj[prop] is not None:
                return obj[prop].encode('utf-8')
        return ''
    else:
        if prop in obj:
            if obj[prop] is not None:
                return obj[prop]
        return None