def get_pt2262_cmd(device_id, data_bits):
    """Extract and return the data bits from a Lighting4/PT2262 packet."""
    try:
        data = bytearray.fromhex(device_id)
    except ValueError:
        return None
    mask = 255 & (1 << data_bits) - 1
    return hex(data[-1] & mask)
